GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   Regex gurus help the noob (https://gfy.com/showthread.php?t=1099554)

madtwin 02-11-2013 04:51 PM

Regex gurus help the noob
 
I have url:

http://gallys.40somethingmag.com/ima...=XXXXXXXXXXXXX

I need regex to get url without NATS code:

http://gallys.40somethingmag.com/ima...tyBlaze_28866/


I have this regex: .*\?.*?
but I end up with url like this:
http://gallys.40somethingmag.com/ima...yBlaze_28866/?

:helpme:helpme:helpme

Barry-xlovecam 02-11-2013 10:31 PM

Use a split
 
Simpler to use a split; "\?"
Code:

#!/usr/bin/perl

use strict;
use warnings;


my $URLstring = "http://gallys.40somethingmag.com/images/BettyBlaze_28866/?nats=XXXXXXXXXXXXX";

our @url = split  /\?/, $URLstring;

print $url[0] ."\n";

exit;
#output
#12:24 AM barry@server:~/Desktop$ ./split.cgi
#http://gallys.40somethingmag.com/images/BettyBlaze_28866/

or regex then just substr 0, -1 ( in perl chop $url[0];)

madtwin 02-12-2013 01:35 AM

Thank you :thumbsup

hotbodybattles 03-08-2013 07:31 PM

Regexbuddy is my best friend when writing perl and doing regex.. i used it more than anything when i was an automation engineer back at an old job.. now i'm writing perl code again at work and using it again... it's 40 bucks to buy though.. but you can probably torrent it.. but i didn't say that.

but do a google search for Regexbuddy and the second hit down will be a thread on stackoverflow called "Is there anything like RegexBuddy in the open - Stack Overflow"

that has some nice tools listed... if you still need em...

regex'es can be a bitch.. or easy... sometimes you have to think outside the box and break down the string a bit more prior to regex'ing it..

good luck


All times are GMT -7. The time now is 12:29 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc