Jump to content

[SOLVED] realy easy preg_match I bet


bbunlock

Recommended Posts

I have never needed to use anything like this (finding a string of text) so I have no idea how to do this, I did try going to php.net and looking there and on here but its all just going over my head, I have no doubt this is going to be childs play for one of you guys/gals but my head is now numb with this.

 

can anyone tell me how I would get the following details for this string of text (sent by $_POST)

 

this is an example of what the $_POST woiuld contain

 

http://www.mysite.co.uk/tc_test/_resources/signals/s60-3/indi2/sig2.png

 

and what im looking to extract from it is the "indi2" however the "indi2" could change depending on what was sent, it could be "indi3, indi4, etc"  but it will always be indi followed by a number(s)

 

if anyone could help me out that would be great.

 

thanks in advance

 

wayne

Link to comment
Share on other sites

There is lot information about regex out there. Many easier places then php.net to learn php. Just do a google search for regex php tutorial or somthing.

 

Ok, so now over to your question. If it is allways indi + number you are looking for then a code like this should solve it.

 

preg_match('/indi[0-9]+/i', 'http://www.mysite.co.uk/tc_test/_resources/signals/s60-3/indi2/sig2.png', $result);

 

You can test it at my regex tester at http://regex.larsolavtorvik.com.

 

Hope this helps!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.