![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
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 |
| With Regex Spliting the string into Alphanumeric and Numeric part | ozgurgul | Shell Programming and Scripting | 1 | 06-30-2007 09:52 AM |
| AlphaNumeric String Operations | lakshmikanth | UNIX for Dummies Questions & Answers | 3 | 01-05-2007 06:55 AM |
| String matching | mpang_ | Shell Programming and Scripting | 3 | 07-28-2006 05:45 AM |
| sed problem - replacement string should be same length as matching string. | amangeles | Shell Programming and Scripting | 4 | 01-11-2006 06:11 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
how to match an alphanumeric string like the following.
i have to do like the following. if the input line is the data is {clock_91b} i have to replace that with the string was ("clock_91b") i tried like $line =~ s/the data is\s+\{([a-z]+)\}/the string was \(\"$1\"\)/ which is not working. Is there any idea? ![]() |
|
||||
|
Well, sounds like homework to me, but looks like you have already put in the effort, and close to a solution, so I will reply (and chastise me if I shouldn't have, guys).
My solution does not use $1 (I need a little sed research myself), but instead uses \1 to back-reference the 1st parenthesized expression: echo 'your input line' | sed "s/the data is {\(.*\)}/the string was \(\"\1\"\)/" and I did not have to escape the braces with backslashes. Jimbo |
|
||||
|
thanks jimbo, i could do that like this
$line =~ s/the data is {(.*)}/the string was \(\"$1\"\)/; sorry for the confusion, since this is a model of the actual problem i faced. I could not give my company data directly here which would have been a solution for your doubt! But sometimes it does not hear good to listen such comments when somebody tends to ask a question after a hectic session of trial in the office along with the tensions to finish the things within the last quarter of the year!! well, thanks anyway. ![]() |
|
||||
|
My apologies, sskb. I am fairly new to this forum, and I will get better at spotting homework as opposed to someone trying to get their job done. I want to help (and learn in the process of helping), and follow the forum rules in the process.
I hope your year-end goes well, and Happy Holidays. |
|
||||
|
thanks Jimbo for your understanding.
well, I am sorry if I have hurt you!! wish you a happy christmas! ![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|