I want to make a redirection on an url :
/XX/YY/ZZ%3E%3E%3E%3E%3E%3E%3E%3E%3E => /XX/YY/ZZ
I don't find the good regex to remove multi match "%3E" at the end of the url.
Can you help me please ?
This should work (for actual URLs with the indicated kind of suffix):
x = "https://www.test.com/XX/YY/ZZ%3E%3E%3E%3E%3E%3E%3E%3E%3E"
s.gsub(/(%3E)+$/,"")
Try this pattern:
\/[\w]{2}
You can test it online
Thank you Human and Drux !
You really helped me to find the solution :
r301 %r{^/XX/([\w\/]*)(%3E)+$}, '/XX/$1'
Related
I need PCRE regex for replace
This
[quote author=MEMBER link=topic=8.msg1111 date=1438798587]
sample text[/quote]
To this one
[quote="MEMBER, post: 1111"]sample text[/quote]
So i need:
Delete attribute date=xxxxxxxxxx and place " in end of tag (after post id)
Replace link=topic=8.msg to post:
Replace author= to ="
Can sombody help please?
Thanks!
Well, you can try this :
\[quote\sauthor=([^\s]+)\s*.*?msg(\d+)\s[^]]*]\s*([^[]*)(\[\/quote])
See this demo.
Although I can't be sure this is really standard to your kind of inputs since you only provided one sample.
I need some help with URL matching regex. I read the regex syntax documentation but it's so complex.
I'm trying to create a URL list for a checkout funnel, how would I set up regex for the following?
https://shop.mysite.ca/[unique ID]/checkouts/[unique ID 2]
OR
https://shop.mysite.ca/[unique ID]/checkouts/[unique ID
2]?step=contact_information
What I have so far, though not sure how to put the optional parameter "step=contact_information")
/^(https:\/\/shop.mysite.ca\/)([\da-z]+)(\/checkouts\/)([\da-z]+)$/
You can use a "?" to make a group either appear 0 or 1 times, making it optional.
/^(https:\/\/shop.mysite.ca\/)([\da-z]+)(\/checkouts\/)([\da-z]+)(\?step=contact_information)?$/
this should work
^(https:\/\/shop.mysite.ca\/)([\da-z]+)(\/checkouts\/)([\da-z]+)((\?step=contact_information)*)$
edit: forgot the ? and used * instead. The other solution by #thomas is a bit better I think
Try it:
^(https:\/\/shop.mysite.ca\/)(\d+.)(\/checkouts)(\/)(\d+.)($|\?\w.+$)
If unique ID is composed with non numbers characteres:
^(https:\/\/shop.mysite.ca\/)([\da-zA-Z]+.)(\/checkouts)(\/)([\da-zA-Z]+.)($|\?\w.+$)
Problem: I need a Regex which would check a given author URL is valid or not.
Requirement : Author URL is basically a URL from social networking sites/blogs etc having author id (profile id)
For eg .
www.facebook.com/RyanMathews
www.mouthshut.com/zobo.786
The regex as per my understanding would have to accept any string(combination of any characters ) after the sites complete address is followed by a " / " .
Tried Using this regex but doesnt support author ids
var urlregex = /^((https?:\/\/)?((([a-z\d])+(\-)?([a-z\d])+)+)(\.([a-z\d])+(\-)?([az\d])+)?)(\.[a-z]{2,4}?){1,2}$/i;
PS : Please explain the Regex & Logic too :D
it should Help but I will recommend to do little background reading.
What is the best regular expression to check if a string is a valid URL?
Getting parts of a URL (Regex)
Please spend some time to read these links and understand them, hope this helps, cheers!
^(http:\/\/){0,1}(www.[^\W]+.com)(\/[^\W]+)+
maybe this would work
I am not very familiar with Regular expression, but I am asked to modify a lighttpd rewrite rule.
url.rewrite = (
"^/(.+)/?$" => "/index.php/$1"
)
I want to exclude a path from the above greedy pattern, so that it won't fall back to index.php.
In words, it is simple: Match anything other than "statistics". But I just couldn't get it right in regex.
For example:
http://www.foo.com/anything/ → index.php/anything
http://www.foo.com/statistics/ → statistics/index.php
Would you please show me a hint to achieve that?
Thank you!
You probably want to use a negative lookahead. Something like
"^/(?!statistics)(.+)/?$" => "/index.php/$1"
And then you'll need an additional rule for statistics
i want to grap data from this site by regexp
http://aymanalrefai.wordpress.com/2010/03/15/596/
i tried this
/<div class="entry">.*?<p class="postinfo">/is
but it didn't give me a correct result
any help ?
Try this :
/<div class="entry">[\s\S]+?</div>/is