d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need A Regex > Pls Halp!
Add Reply New Topic New Poll
Member
Posts: 6,864
Joined: Dec 5 2007
Gold: 0.90
Aug 12 2014 11:10am
url/foo/this:bar

i need to check if theres a word in the url. its allways the same pattern. foo/ before : afterwards.

will /regex/.test(myword) work then?
thx guys!
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Aug 12 2014 01:47pm
What language?

You can just match against a list of words like so

Code

data =~ /this|bar|foo/


Of if you need to capture a specific word you can enclose the regex in brackets which will return the match.

Go to http://rubular.com/ it's meant for ruby but regex is roughly the same for all languages.
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
Aug 12 2014 04:56pm
I suck at regexes but something like
Code
foo/[a-z]*:
maybe?
Member
Posts: 8,110
Joined: Sep 23 2006
Gold: 3,558.23
Aug 12 2014 08:17pm
Powershell can do this too.
What else are you trying to do? Do you have a text file that feeds all the url's to you?
Member
Posts: 62,204
Joined: Jun 3 2007
Gold: 9,039.20
Aug 13 2014 12:10am
Quick dirty and will probably break

Code
[http|https].*\/(.*):.*


It is sure to find whatever is before the colon, since it makes a nice delimiter.

If you post more information maybe I can make it more explicit.
Member
Posts: 859
Joined: Jul 2 2008
Gold: 27.00
Aug 13 2014 06:41am
Member
Posts: 23,728
Joined: Aug 21 2007
Gold: 433.48
Trader: Trusted
Aug 20 2014 10:06am

Code


.*/foo/[^:]*:



should work
Member
Posts: 2,086
Joined: Oct 28 2013
Gold: 3,961.00
Aug 28 2014 01:34am
#px"[:alpha:]{\/{2}}[[[word]]+\/]+\/[[[word]]\:[[word]]"
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll