regex for 3 numbers after string - regex

I've a problem, I have a link on each page of my website linking to a different contact form which does'nt exist. for example, on one page it links to contact_123.html, another contact_122.html, another contact_124.html etc... I want to do a find and replace on this to change any contact_"any 3 numbers".html to just contact.html.
Does anyone know the regex to do this. Cheers!

Regex to search for: contact_\d{3}\.html
How to do actual search&replace depends what tool/environment you're using

Related

Regex for Google Analytics Goal

I've searched all the other Regex on Google Analytics questions but I can't use the answers as this is pretty specific to my problem.
I want to set a destination URL goal but use Regex to flag it as a goal IF string includes /general/
I basically want to track everyone in GA who goes to a Vehicle Detail Page but /general/ brings them to a Search Results Page.
so in other words
/used-cars/general is not correct
/used-cars/citreon/ is correct
/used-cars/TOYOTA/ is correct
Basically, any other car maker is correct after /used-cars/ regardless if it is capitalized or not.
Thanks in advance, everyone.
Your regex is on the right path, but you should escape any special characters. Try the below instead:
/used\-cars/(citreon|TOYOTA|RENAULT|VOLKSWAGEN|VAUXHALL|HONDA|BMW|NISSAN|PEUGEOT|DS|FORD|HYUNDAI|INFINITI|MERCEDES\-BENZ|MITSUBISHI)/

Google Form Validate a specific URL Regex

I am creating a google form and trying to create a regex on of the fields because I need them to enter a profile link from a specific website. I'm a beginner with regex and this is what I have come up with:
/^(http:\/\/)?(steamcommunity\.com\/id\/)*\/?$/
But when I go to enter a test link such as: http://steamcommunity.com/id/bagzli it fails it. I don't understand what is wrong about it.
You missed a dot (meaning any character) after the (/id\). Try this:
/^(http:\/\/)?(steamcommunity\.com\/id\/).*\/?$/
^-- added
The ultimate goal of what I was trying to accomplish is to ensure that certain text was entered in the box. I thought I had to use Regex to accomplish that, but google forms also has "Text Contains" feature which I made use of to solve my problem. The regex by Zoff Dino did not work, I am not sure why as it seems completely correct.
I will mark this as resolved as I managed to get my answer, even if it was not via regex.

Regex find urls and replace with bbcode

I'm writing program that replace link with bbcode. I need a regex that replace url with bbcode, example:
before
http://mediafire.com/abc (or http://dropbox.net/abc,...)
I want to filter that name of link also
after
[url=http://name-of-link.com/abc]http://name-of-link.com/abc[/url]
This is what I have got so far:
Search for:
(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,#?^=%&:\/~+#-]*[\w#?^=%&\/~+#-])?
Replace with:
[url=$1]$2[/url]
But it seems doesn't work. Hope anyone can help me out this issue. Thank you.
Edit:
My issue that I want to filter name of link also, because I don't want to replace link of image to bbcode.

What is the regex for a URL like this?

I don't really know regex, but would like a quick solution to search and replace links. I want to use the search regex wordpress plugin to remove links in my post. How do I format the regex to a link like this:
http://website.com/index.php?id=934&title=item name
edit: the numbers in the id and the item name varies
Thank you in advance!
Try this one out: http://regexr.com?2vjq6
Depending on whether or not you need whitespace in your "title" parameter, the regex I provided may need to be altered. Best practice would be to not have whitespace in your URLs (use URL encoding instead, where a space = %20).
http://website.com/index.php\?id=[0-9]*&title=[a-zA-Z0-9\-]*
Try this pattern
(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,#?^=%&:/~\+#]*[\w\-\#?^=%&/~\+#])?

I am trying to create an expression that will extract URLs

I want to extract URLs from a webpage these are just URLs by themselves not hyperlinks etc., they are just text. Some examples would be http://www.example.com, http://example.com, www.example.com etc. I am extremely new at regex so I have copy and pasted like 20 expressions online all failed to work. I don't know if I am doing it right or not. Any help would be really appreciated.
I wrote a post on using Regex to locate links within a HTML page (the intent was to use JavaScript to open external links or links to documents such as PDF's etc in a popup window).
The final regex was:
^(?:[./]+)?(?:Assets|https?://(?!(?:www.)?integralist))
The full post is here:
http://www.integralist.co.uk/javascript/regular-expression-to-open-external-links-in-popup-window/
The solution wont be perfect but might help point you in the right direction.
Mark
You're probably not escaping your .s. You need to use \. for each one.
Take a look at strfriend.com. It has a URL example, and represents it graphically.
The example it suggests is:
^((ht|f)tp(s?)://|~/|/)?(\w+:\w+#)?([a-zA-Z]{1}([\w-]+.)+(\w{2,5}))(:\d{1,5})?((/?\w+/)+|/?)(\w+.\w{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?