Home: Perl Programming Help: Regular Expressions:
Post deleted by leorob



leorob
Novice

Oct 19, 2011, 7:28 AM


Views: 11553
Post deleted by leorob

 


rovf
Veteran

Oct 20, 2011, 8:21 AM


Views: 11538
Re: [leorob] extract substrings

Write a regexp describe your string. Use parenthesis inside your string to capture the parts you are interested in. Use special variables $1, $2 etc. to refer to the captured substring.


wickedxter
User

Oct 22, 2011, 9:38 AM


Views: 11490
Re: [leorob] extract substrings

is this being read from a file or is it all in a single variable?


Code
  

my $string =~ /Trap\s\((\d+)\)/m;

print $1;

my $string2 =~ /cmgTrapLocation\.\d\s\=\sSTRING\:\s"(.+)"\s/m;

print $1;



try this


leorob
Novice

Oct 23, 2011, 11:24 PM


Views: 11337
Post deleted by leorob

 


leorob
Novice

Oct 23, 2011, 11:24 PM


Views: 11336
Post deleted by leorob

 


leorob
Novice

Oct 25, 2011, 11:38 PM


Views: 11123
Post deleted by leorob

 


leorob
Novice

Oct 25, 2011, 11:58 PM


Views: 11121
Post deleted by leorob

 


wickedxter
User

Oct 27, 2011, 3:58 AM


Views: 11030
Re: [leorob] extract substrings

have you tried this with any luck? post any errors or unxepectied results.