Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

perl regular expression

Name: Anonymous 2010-01-13 19:26

for matching an URL string
well, i found this but it's not working:
 '(http|https)([:\/\w\s\d\.]*)/i'

Name: Anonymous 2010-01-13 19:27

'(http|https)([:\/\w\s\d\.]*)/i'

Name: Anonymous 2010-01-13 19:33

s!'!/'!

note the lack of /g

Name: Anonymous 2010-01-13 19:36

found
FFS this is elementary school material, can't you write one yourself?

Name: Anonymous 2010-01-13 19:38

that's a pretty bad regex.
(https?://)?([-_\w\d\.\/]*)
here's my cleaned up, and untested version.

Name: Anonymous 2010-01-13 19:38

in before two problems

Name: Anonymous 2010-01-13 19:40

>>6
only people that don't understand regexes are afraid of them.
they are extremely useful in skilled hands

Name: Anonymous 2010-01-13 19:52

>>5
really good bro, works like a charm

Name: Anonymous 2010-01-13 19:57

:\/
lol'd at OP

Name: Anonymous 2010-01-13 20:03

>>5
(https?://)([-:_\w\d\./]*)
better

Name: Anonymous 2010-01-13 20:15

>>1
matching an URL string
Perhaps your looking for:
    /[-+.a-z]+:(?:[-\w+.\$!*'(),;\/?:\@&=]+|%[\da-f]{2})*/i

Name: Anonymous 2010-01-13 20:19

>>10
not really, it stops after http://www.

Name: Anonymous 2010-01-13 21:23

OK ATTENTION PLS:

im using these 2 now:
'(https?|ftp|ssh)?(://)?(www.)([;:\/\w\s\d\.\-\_\?\=]*)( )'
and
'(https?|ftp|ssh)(://)([:\/\w\s\d\.\-\_\?\=]*)( )'

is it possible to combine these two?

Name: Anonymous 2010-01-13 21:26


Name: Anonymous 2010-01-13 21:31

>>14
you shure showed him

Name: Anonymous 2010-01-13 22:11

have some test suite:
url 1. http://example.com/
url 2. http://www.example.com/
url 3. http://www.example.com:80/
url 4. http://www.example.com:80/Taste-banana.htm
url 5. https://example.com:8080/?page=test
url 6. https://example.com:8080/?page=test&subpage=7
url 7. https://example.com/unicode%E3%81%82
url 8. http://example.com/url+with%20spaces
url 9. www.asd.com/+asd&cd=1&hl=en&;ct=clnk" target='_blank'>http://209.85.129.132/search?q=cache:dABs2UlbjJgJ:www.asd.com/+asd&cd=1&hl=en&;ct=clnk
url 10. 4E29E23889B7@eris.apache.org%3E" target='_blank'>http://mail-archives.apache.org/mod_mbox/portals-pluto-scm/200902.mbox/%3C20090220223713.4E29E23889B7@eris.apache.org%3E
url 11. http://11example.org/~user/groar_v1.0.html
url 12. example.com/asd.htm#profit
url 13. www.example.com/America.ogg
url 14. http://example.com/[L]%20brackets(arefun).swf
url 15. http://example.com/"><h1>bidoof is on fire.html
url 16. http://asd.com"onclick="alert('weather forecast')
url 17. http://asd.com"style="background:black"/node304.html
etc.

Name: Anonymous 2010-01-13 22:18

>>16
heh, engine failed on url 9 and 10. just delete junk up to target='_blank'> in these lines. (those are completely valid urls, you can copy-paste them into browser.)

url 13 was using & #65; instead of 'A'.

Name: Anonymous 2010-01-14 3:55

>>13
Sorry bud, no way.

Name: Anonymous 2010-11-13 21:56

Name: Anonymous 2011-02-02 23:33

Name: Anonymous 2013-01-19 14:41

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List