Simple Regular Expression.

From: EFP (epridgett_at_woh.rr.com)
Date: 11/26/03

  • Next message: Gunnar Hjalmarsson: "Re: Simple Regular Expression."
    Date: 26 Nov 2003 08:24:01 -0800
    
    

    Can anyone help me with a simple regular expression problem.

    All that I want to do is take a list of known data and extract a
    particular section of the string to form a new list.

    Here is my code snipet:

    my $fh = new FileHandle('c:\Units.txt') ; ## sucks up my work file
    my @lines1 = <$fh>; ## assigns the filehandler contents to @lines1
    foreach $string (@lines1) ## extract each line from @lines and put it
    in $string
    {

    $string =~ m/\*@@\$/;

    print "NewString :: $string\n";
    }

    Sample Units.txt data:
    .\Source\CPP\ConnPool\src\oraUtils.pc@@
    .\Source\CPP\ConnPool\src\sample.pc@@
    .\Source\CPP\Services\src\OExceptServer.pc@@
    .\Source\CPP\Services\src\Rees1440Server.pc@@
    .\Source\CPP\Services\src\SWDTestServer.pc@@
    .\Source\CPP\TestCases\TestRees1800\testRees1800Cursor.pc@@
    .\Source\CPP\TSRI\Remis1\cxxsrc\Buffer_Area.pc@@

    I just want the:
    oraUtils.pc

    I'd even settle for:
    oraUtils.pc@@

    So basically I want the contents between "\" and the "@@"

    I thought that:
    $string =~ m/\*@@\$/;

    Would go to the end of the search line and find "@@" and get anything
    "*" between the "@@" and the "\" and set $string to this new value.

    What it returns is:
    element:: .\Source\CPP\ConnPool\src\oraUtils.pc@@

    Can anyone correct my understanding of regular expression and
    assignment to a varibale.

    Thanks.
    EFP


  • Next message: Gunnar Hjalmarsson: "Re: Simple Regular Expression."

    Relevant Pages

    • Re: Get regular expression
      ... own tree structure. ... Expression compares a string character-by character, ... regular expression solution, which was about as close as one could get to ... the structure of the hierarchy can be inferred by using ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Get regular expression
      ... regular expression solution, which was about as close as one could get to ... first string. ... explode "ABLATION" and see subnodes of "ENDOMETRIAL ... "Heart 27.33/2" ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Extracting Strings
      ... regular expression and php function that does it. ... I want to extract the data in the following string: ... The characters in the square brackets are the characters to match ...
      (alt.php)
    • Re: Extracting Strings
      ... regular expression and php function that does it. ... I want to extract the data in the following string: ... The characters in the square brackets are the characters to match ...
      (alt.php)
    • Re: Extracting a numbers from a text string
      ... thorough understanding of the application's potential. ... The Regular Expression is the section within the double quote marks. ... Look for a space (but don't extract it) ... a string of digits ...
      (microsoft.public.excel.worksheet.functions)