Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Looking for a Regex

by davies (Prior)
on Mar 03, 2019 at 18:50 UTC ( [id://1230799]=note: print w/replies, xml ) Need Help??


in reply to Looking for a Regex

I, too, believe that what you want is a regex. I also agree with 1nickt that this isn't a code writing service. Assuming from your uncertainty that you are unfamiliar with regexes - a terrifyingly complex subject - let me try to get you started.

Character classes seem to be what you want. There are lots of resources on line, for example https://www.regular-expressions.info/charclass.html. You may or may not need different classes for each of your parts. A class for letters, digits and the other three you mention might be:

[a..z0..9'-_]

Using i after the final slash will make the regex case insensitive, meaning that you don't need to include upper case letters as well.

If you are familiar with testing, I recommend writing this as a series of tests to build up the regex one requirement at a time. Your test file will then explain to you in six months' time what you were trying to do. You won't remember otherwise. If you aren't, testing is a very useful tool to learn.

Regards,

John Davies

Log In?
Username:
Password:

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

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

    No recent polls found