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.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-24-2012, 02:17 PM   #1
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Regex perts..

Can anyone help with this simple regex really quick, the shit always mind fucks me.

I need to split this:

ASDFjpgQWERjpg

into:

[0] => ASDFjpg [1] => QWERjpg

Can split it with 'jpg' but don't know how to keep the jpg on the end of them.

Please save me from this hour long headache
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-24-2012, 02:33 PM   #2
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
/^([A-Z]+jpg)([A-Z]+jpg)$/

or if you're wanting php preg_match:

preg_match("/^([A-Z]+jpg)([A-Z]+jpg)$/", $matches);
var_dump($matches);
__________________

For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)



All models are wrong, but some are useful. George E.P. Box. p202
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-24-2012, 02:34 PM   #3
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
or if the pattern occurs ad nauseum

preg_match_all("/([A-Z]+jpg)/", $matches);
var_dump($matches);
__________________

For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)



All models are wrong, but some are useful. George E.P. Box. p202
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-24-2012, 02:42 PM   #4
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Should have mentioned there might be a long list of them and not just 2.

This is the best I could do and it works but it's messy and returns too much other shit

preg_match_all("/([A-Za-z0-9]{4}(jpg|jpeg|gif|png))/","ASDFjpgBLAHjpgQWERjpg",$matches);

Edit: ok this is better but still returning a bunch of "jpg" on the end.

preg_match_all("/[A-Za-z0-9]{4}(jpg|jpeg|gif|png)/","ASDFjpgBLAHjpgQWERjpg",$matches);
__________________
[email protected] - jakezdumb - 573689400

Killuminati

Last edited by Jakez; 02-24-2012 at 02:46 PM..
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-24-2012, 02:47 PM   #5
margarita
Confirmed User
 
Join Date: Jun 2003
Posts: 917
([A-Za-z0-9]{4}(?:jpg|jpeg|gif|png)) to remove that jpg, etc. from results
__________________
Check out my favourite kinky sponsor and must-have tool Nifty Stats
margarita is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-24-2012, 02:50 PM   #6
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
preg_match_all("/[A-Za-z0-9]{4}(?:jpg|jpeg|gif|png)/","ASDFjpgBLAHjpgQWERjpg",$matches);

perfection! Thanks dudes!!
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-24-2012, 02:54 PM   #7
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by margarita View Post
([A-Za-z0-9]{4}(?:jpg|jpeg|gif|png)) to remove that jpg, etc. from results
^^^ what he said for look ahead matching (plus don't listen to me, cos I forgot the $subject )

Code:
preg_match_all("/([A-Za-z0-9]{4}(?:jpg|jpeg|gif|png))/","ASDFjpgBLAHjpgQWERjpg",$matches);
__________________

For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)



All models are wrong, but some are useful. George E.P. Box. p202
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-24-2012, 06:41 PM   #8
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,409
Too late to make an entry for the contest?
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2012, 12:05 AM   #9
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Quote:
Originally Posted by V_RocKs View Post
Too late to make an entry for the contest?
Give it your best.
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2012, 06:57 AM   #10
Barry-xlovecam
It's 42
 
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
s/jpg/\.jpg/;
Barry-xlovecam is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2012, 09:45 AM   #11
HomerSimpson
Too lazy to set a custom title
 
HomerSimpson's Avatar
 
Industry Role:
Join Date: Sep 2005
Location: Springfield
Posts: 13,826
if can you use php

Code:
$x = ""; // that string with all that junk
$a = array(); // resulting array
$x str_replace('jpg', 'jpg|',$x);
$a = explode('|', $x)
var_dump($a);
that should do the trick
__________________
Make a bank with Chaturbate - the best selling webcam program
Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!!

PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email:
HomerSimpson is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.