Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

RegEx question

by mohamedrabeek (Initiate)
on Jul 23, 2010 at 12:25 UTC ( [id://851026]=perlquestion: print w/replies, xml ) Need Help??

mohamedrabeek has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: RegEx question
by moritz (Cardinal) on Jul 23, 2010 at 12:31 UTC
    Please test it before giving me the solution.

    Is this another "please do the work for me" thing? If you want good answers, a nice way is to provide the testing code yourself, so that people just need to plug in their regexes.

    Anyway, my approach would be /^(?!.*, $)/

    Perl 6 - links to (nearly) everything that is Perl 6.
Re: RegEx question
by roboticus (Chancellor) on Jul 23, 2010 at 12:33 UTC

    mohamedrabeek:

    Hint: It would be easy to match all other lines. You can get that one, right?

    If not....

    ...roboticus

Re: RegEx question
by zek152 (Pilgrim) on Jul 23, 2010 at 12:48 UTC

    Show what you used so we can help you learn why it did not work. The code below shows a working solution. It is not very elegant but it does work:

    $line1 = "this is an example"; $line2 = "this is another example,"; $line3 = "this is yet another example "; $line4 = "despite what you think this is not an example, "; if ($line1 !~ /.*,\s*$/) { print "MATCHED : $line1\n"; } else { print "MISMATCH: $line1\n"; } # ... repeated for $line2 $line3 and $line 4 ########################################################## # Output #MATCHED : this is an example #MISMATCH: this is another example, #MATCHED : this is yet another example #MISMATCH: despite what you think this is not an example, ##########################################################
Re: RegEx question
by ahmad (Hermit) on Jul 23, 2010 at 12:54 UTC

    Like this?

    while (<DATA>) { if (!/,\s+$/) { print; } } __DATA__ 1) this is an example 2) this is an example, 3) this is an example, 4) this is an example
Re: RegEx question
by japhy (Canon) on Sep 21, 2010 at 19:29 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://851026]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-16 22:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found