× Here you can get community support related to ReDJ.

Simple RegEx

  • voipits
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 weeks ago #2247 by voipits
Simple RegEx was created by voipits
I'm sure this is dirt simple for everyone, but I have been trying for countless hours.

OLD URL:

/blog/item/[ID]-[postname]

NEW URL:

/blog/[postname]

This can catch all of the right pages:

^/blog/item/[0-9]{1,3}-


I am just having the worst time getting the post name with placeholders, it never gets anything, I am always redirecting to just /blog/

Sometimes there is extra at the end of the URL, I don't really care if this gets carried over, but it is important to note for the purposes of getting the right info for the placeholder, for example:
www.voipits.com/blog/item/33-is-voip-technology-environmentally-friendly#.Uva3J7Ktrzk.facebook

so sometimes it can end
/blog/item/33-is-voip-technology-environmentally-friendly
or
/blog/item/33-is-voip-technology-environmentally-friendly/
or
/blog/item/33-is-voip-technology-environmentally-friendly#.Uva3J7Ktrzk.facebook


Some samples:

www.voipits.com/blog/item/52-how-to-adjust-router-qos --> www.voipits.com/blog/how-to-adjust-router-qos
www.voipits.com/blog/item/33-is-voip-technology-environmentally-friendly#.Uva3J7Ktrzk.facebook --> www.voipits.com/blog/is-voip-technology-environmentally-friendly


Please help before I go crazy. THANKS!

Please Log in or Create an account to join the conversation.

More
10 years 2 weeks ago #2248 by admin
Replied by admin on topic Simple RegEx
Hi,
if you can have:

/blog/item/33-is-voip-technology-environmentally-friendly
or
/blog/item/33-is-voip-technology-environmentally-friendly/
or
/blog/item/33-is-voip-technology-environmentally-friendly#.Uva3J7Ktrzk.facebook

Then the placeholder to extract ONLY is-voip-technology-environmentally-friendly should be:
a={preg_match 1}/\/blog\/item\/[0-9]+-([^\/#]+)/i{/preg_match}

Not tested, so let me know if doesn't works.

Kind regards,
Luigi
The following user(s) said Thank You: voipits

Please Log in or Create an account to join the conversation.

  • voipits
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 weeks ago #2257 by voipits
Replied by voipits on topic Simple RegEx
I should have updated my message but I did figure this out after looking through countless examples. I did it slightly different though, I am going to use your method instead. With mine, it keeps everything after the blog ID numbers whereas yours ends at the end of the blog name which is perfect.

Thanks

Please Log in or Create an account to join the conversation.

More
10 years 2 weeks ago #2260 by admin
Replied by admin on topic Simple RegEx
U're welcome :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.069 seconds