Current location: Hot Scripts Forums » Programming Languages » Perl » suggest a regular expression


suggest a regular expression

Reply
  #1 (permalink)  
Old 01-07-04, 12:56 PM
gmadhukarreddy gmadhukarreddy is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
suggest a regular expression

i have a line like ....

123..345,456..567,678..789

and i have to substitute each number (like 123) by adding something to it (all at one go - the whole line)

so if i have to add 20 to each,

the regular expression should substitute 123 by 143 (i.e.123+20 )
345 by 365
456 by 476 and so on

so how can I write the regular expression ????

can I write something like

$a =~ s/\d+/eval($&+20)/g;

where i need to get the evaluated value to be substituted. but it is not evaluating...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-07-04, 03:24 PM
Chas Chas is offline
Coding Addict
 
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
Check out my reply to your original thread:

http://www.programmingtalk.com/showt...7558#post17558

~Charlie
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-08-04, 01:56 AM
gmadhukarreddy gmadhukarreddy is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
thanks

your code works great.......thanks charlie
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions helpcenterlive PHP 2 12-08-03 07:56 PM
Regular Expressioning []'s AbelaJohnB PHP 8 12-04-03 03:37 PM
Syntax error (missing operator) in query expression crobinson ASP 4 11-23-03 09:49 PM
Regular expression khibinite PHP 3 11-20-03 09:23 AM


All times are GMT -5. The time now is 01:03 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.