Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: RegExp quick question

by plaid (Chaplain)
on Apr 04, 2000 at 00:57 UTC ( [id://6757]=note: print w/replies, xml ) Need Help??


in reply to RegExp quick question

I'm also not quite sure what you're going for here. If you have a word such as 'foo.bar', you'd probably just want to do something like
my($before, $after) = split(/\./, $word);
Or, if the word might contain multiple periods
my @tokens = split(/\./, $word);
If you need to check that there is a period in the word, you should use the if statement posted above before splitting. If you want to verify that a word contains only letters, you'd want to do a matching regular expression prior to the split
$word =~ /^[a-zA-Z]+\.[a-zA-Z]*$/;
And potentially throw in some /s* if you want to check for whitespace in it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found