Jump to content

simple pregmatch inverted


nadeemshafi9

Recommended Posts

hi guys

 

can somone give me some links to some solid manuals

 

this is my string #image,100#

 

i need to get the 100

 

any ideas

 

im just about to dl a cheetsheet will be back soon to see what has been suggested, this is the first regex of this new job of mine so iim slightly out of knowledge on it atm, was using it a lot at the last job

 

http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/

 

should be bale to knock something up i n a bit

Link to comment
https://forums.phpfreaks.com/topic/179345-simple-pregmatch-inverted/
Share on other sites

this is my string #image,100#

 

i cant find anything to negate /#image.*#/ regexp, so im thinking its the wrong way to go about it, do i really need regex in this ?

 

split the string by ,

 

strip off #image

and #

 

actualy if i can negate  regexp /#image.*#/

 

i can then split the result by ,

I take it it always says #image then? You could simply use trim to remove the hashes then explode on the comma. But if you want to use Regular Expressions then something like...

 

~^#image,(\d{3})#~

 

That of course assumes the 100 is always a 3 digit number. You can modify that accordingly.

I take it it always says #image then? You could simply use trim to remove the hashes then explode on the comma. But if you want to use Regular Expressions then something like...

 

~^#image,(\d{3})#~

 

That of course assumes the 100 is always a 3 digit number. You can modify that accordingly.

 

thanku

#picture(.*)#

should be

 

#picture,(.*?)#

or

better still

#picture,(\d+,\d+)#

 

but if you want to match all of these

#picture,100#
#picture,100,100#
#picture,100,100,100#
#picture,100,100,100,100#
etc etc etc

then this would be better

#picture,(\d+(?:,\d+)*)#

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.