The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-11-2001
sskb
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Question matching alphanumeric string

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?
  #2 (permalink)  
Old 12-11-2001
Jimbo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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
  #3 (permalink)  
Old 12-11-2001
sskb
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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.
  #4 (permalink)  
Old 12-12-2001
Jimbo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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.
  #5 (permalink)  
Old 12-12-2001
sskb
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
thanks Jimbo for your understanding.
well, I am sorry if I have hurt you!!
wish you a happy christmas!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0