![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ksh - test if string contains alphanumeric... | tugger | Shell Programming and Scripting | 3 | 10-16-2007 04:23 AM |
| alphanumeric comparision | rakeshou | Shell Programming and Scripting | 3 | 09-27-2007 11:32 AM |
| With Regex Spliting the string into Alphanumeric and Numeric part | ozgurgul | Shell Programming and Scripting | 1 | 06-30-2007 09:52 AM |
| String Operations | Rohini Vijay | Shell Programming and Scripting | 9 | 04-21-2006 11:32 AM |
| matching alphanumeric string | sskb | Shell Programming and Scripting | 4 | 12-12-2001 10:48 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi
I am writing a ksh I have a string of general format A12B3456CD78 the string is of variable length the string always ends with numbers (here it is 78.. it can be any number of digits may be 789 or just 7) before these ending numbers are alphabets (here it is CD can even be C alone or CDX ..that is length can be varied) before the CD is a string of variable length that always ends in digits here A12B3456 .... i want to extract each of these seperately .. ie part one A12B3456 part two CD part three 78 this is a bit complicated for me ... plz help me out |
|
||||
|
Code:
# !/opt/third-party/bin/zsh
str="A12B3456CD78"
only_num=$(echo $str | tr '[A-Za-z]' ' ' | awk '{print $NF}')
only_alpha=$(echo $str | tr '[0-9]' ' ' | awk '{print $NF}')
echo $str $only_num $only_alpha | awk '{ print (substr ($0,0,length($1) - ( length($2) + length($3) ))), "\n", $2, "\n", $3 }'
exit 0
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|