Results 1 to 2 of 2

Thread: perl regex string match issue..kindly help

Hybrid View

  1. #1
    Join Date
    Oct 2012

    perl regex string match issue..kindly help

    i have a script in which i need to skip comments, and i am able to achieve it partially...
    IN text file:

    {test : test...test }

    while (<$fh>)

    push ( @data, $_);

    if ( $data[0] =~ m/(^{\*+$)/ ){
    With the above match i am able to identify the comment and skip it to get the next line..
    {test : test...test }
    If the same comment consists of any space or any character in the place of *, my match fails..
    {** ***** or {* abccd or {*abce
    All the above cases are failed to skip ... What might be worng in the match,...can any one help me out..

  2. #2
    Join Date
    Oct 2007
    Vienna, Austria
    That's what you write in your regexp
    ^: line start
    {: literal "{"
    \*: literal "*"
    +: repetition
    $: end of line
    So if there's anything else than just {******, the match fails.

    Removing the dollar sign from the regexp would do the trick for the examples you gave. But except this is a programming exercise, I'd suggest using an existing syntax with existing, robust parser, instead of re-inventing the wheel.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center