perl - PCRE Regex help needed -
i having trouble writing perl compatible regex match few different things when there gap between each condition. makes more sense when explain want find
conditions
- /world/
- a single letter
- a dash or underscore
- a single letter
- a single period
- three or 4 letters
the problem have don't know how write expression such there can gap between condition #1 , #2. conditions #2 - #4 can repeat, not always.
i've been using multiple online regex testers cannot match , not sure doing wrong. think regex looking /world/x_x
or /world/y-y
instead of "looking ahead" match on "letter dash letter" or "letter underscore letter" pattern.
current regex
/world/([a-z](-|_)[a-z]){1,}\.[a-z]{3,4}$
desired matches (not matching)
hxxp://armassimchilzeispreu.blackjackipad.com/world/activate_available.jar hxxp://chubfaceddamsel0.affittobarcheavela.it/world/eternal_threat-clearing.html hxxp://offdestroyengarabitar.freebookofraslot.com/world/bonus-middle-marathon.pdf
i think want this
use strict; use warnings; while (<data>) { chomp; print "ok $_\n" if m</world/[a-z]+(?:[_-][a-z]+)+\.[a-z]{3,4}$>; } __data__ hxxp://armassimchilzeispreu.blackjackipad.com/world/activate_available.jar hxxp://chubfaceddamsel0.affittobarcheavela.it/world/eternal_threat-clearing.html hxxp://offdestroyengarabitar.freebookofraslot.com/world/bonus-middle-marathon.pdf
or perhaps just
m</world/[a-z-_]+\.[a-z]{3,4}$>
Comments
Post a Comment