CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Perl Pattern Matching !!! Help

 



rahulranjith
New User

Jun 3, 2008, 6:30 PM

Post #1 of 2 (3123 views)
Perl Pattern Matching !!! Help Can't Post

Hello

I got the below one from in one of this forums

For Ex: Loading File System Networking in nature

now i need to extract the patterns between the words File and Networking :

i.e. sample output: System

cmd used : cat <file> | sed 's/.*File //' | sed 's/Closing.*$//'


Actually i have the same criteria but i want to do it from a variable which has special characters ..

For Example :

$VAR=USING (FILE '/TEST1/FILENAME'5000)

From the above string i want to reterive the value between ' and ) in this case its 5000.

Any Suggestions will be helpful

Thanks

Rahul


spider
User


Jul 10, 2008, 1:12 AM

Post #2 of 2 (2913 views)
Re: [rahulranjith] Perl Pattern Matching !!! Help [In reply to] Can't Post

The question will be what you know of the string you are searching in.

In the first case you could do someting like:

if($string =~ /File(.+)Networking/){

$new_string = $1 ;

}



in the last case, if you know FILENAME, and you know you are searching for digits, it could be:

if($VAR =~ /FILENAME\'(\d+)\)/){

print $1 ;

}

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives