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

Re: Regex Question

by Kenosis (Priest)
on Nov 26, 2012 at 05:46 UTC ( #1005563=note: print w/ replies, xml ) Need Help??


in reply to Regex Question

You could use substr for this:

use strict; use warnings; my $string = 'That string is funny!'; if ( substr( $string, 2, 1 ) eq 'a' ) { print 'The third character in $string is an "a".'; }

But if you're set on a regex, the following will match a string whose third character is "a":

$string =~ /^..a/


Comment on Re: Regex Question
Select or Download Code
Re^2: Regex Question
by shealyw2 (Initiate) on Nov 26, 2012 at 06:15 UTC
    Thanks, i don't know why i did not think of substring. That defiantly is an option i should have considered.

      You're most welcome, shealyw2!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2015-07-07 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls