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

Re: regex capture case

by Crian (Chaplain)
on Jun 23, 2009 at 10:26 UTC ( #773947=note: print w/ replies, xml ) Need Help??


in reply to regex capture case

I don't know if it is the right solution for your problem, but did you thought about using ucfirst on the result?


Comment on Re: regex capture case
Re^2: regex capture case
by rmflow (Beadle) on Jun 23, 2009 at 10:32 UTC
    what if
    $_ = "Aabc"; $someRegex = "aA.*";
    then I'll need to uc second char.

    $_ and $someRegex are not known.

      What about

      $someRegex = "(aA|Aa).*";

      ...what effect should that have? Or what about

      $someRegex = "(?!aa)[Aa]+.*"

      Basically, what you're asking for is not feasible in the general case. If you know that $someRegex will always be very simple, it becomes tractable; you can use something like YAPE::Regex to parse the regex and match elements thereof to the extracted string to determine which characters' case needs to change. But for arbitrary regexes, it gets hard quickly.

      Depending on what you actually need this for, you may find it simpler to request both a regex and a case template, or to have your input take the form of a restricted pattern that you yourself can then translate into a regex and a case template.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-09-22 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (200 votes), past polls