![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
|
New Webmasters ask "How-To" questions here. This is where other fucking Webmasters help. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Aug 2009
Posts: 274
|
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/? ![]() ![]() ![]() |
![]() |
![]() ![]() ![]() ![]() |
![]() |
#2 |
It's 42
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
|
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];) |
![]() |
![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Aug 2009
Posts: 274
|
Thank you
![]() |
![]() |
![]() ![]() ![]() ![]() |
![]() |
#4 |
Registered User
Industry Role:
Join Date: May 2011
Location: New England
Posts: 28
|
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 |
![]() |
![]() ![]() ![]() ![]() |