Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

RE: RE: How do I print only some letters of this string

by nuance (Hermit)
on Jun 21, 2000 at 19:39 UTC ( [id://19258]=note: print w/replies, xml ) Need Help??


in reply to Re: How do I print only some letters of this string
in thread How do I print only some letters of this string

I don't think this regular expression does what you think it does. You have not bounded that | term, so it splits your entire regular expression into two. Also you don't need all the stuff at the start since you aren't actually doing anything with it (storing it etc.)

You could achieve your goal with:

/(?:Critical|Minor)\s+(.{0,17})/;

The (?: term groups without creating a back reference. The \s should not use non-greedy matching, using non-greedy matching here will include leading space in the 17 characters if there is more than one space separating the final two fields. Also we want at least one character at that position so + is better than *. The final field needs to be limited to 17 characters, but if there are less, your expression will fail instead of returing as many as it can find.

Nuance

Replies are listed 'Best First'.
RE: RE: Answer: How do I print only some letters of this string
by jlistf (Monk) on Jun 21, 2000 at 19:58 UTC
    good points all of them. i probably should have done a little more debugging on my answer, but i figured the gist would come across. you could also use ?<= instead of ?: but thats a minor detail.

Log In?
Username:
Password:

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

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

    No recent polls found