Skip to content

Tag: regex

How can I find repeating pairs of characters with a regex?

Trying to use regex to replace any occurrences of any set of two characters which repeat in a string. I would like for such patterns to be replaced with one occurrence of the repeating substring and the number of times it was repeated. For example, in this string below, I would like: qwertyabababababababababa…

RegExp for an identifier

I am trying to write a regular expression for an ID which comes in the following formats: 7_b4718152-d9ed-4724-b3fe-e8dc9f12458a b4718152-d9ed-4724-b3fe-e8dc9f12458a [a_][b]-[c]-[d]-[e]-[f] a – optional 0-3 digits followed by an underscore if there’s at least a digit (if there is underscore is req…

How to set the regex for this in javascript?

Usernames are used everywhere on the internet. They are what give users a unique identity on their favorite sites. You need to check all the usernames in a database. Here are some simple rules that users have to follow when creating their username. Usernames can only use alpha-numeric characters. The only num…

JS Regex match numbers between brackets

I have the following code, but getting no output. When I run it here it seems to work: https://regex101.com/r/FVkJfF/1 To clarify, I aim to capture all the values between the brackets if they contain a number (including the opening and closing bracket of that group) Guess I am doing something wrong somewhere?…

JsFiddle URL with trailing slash being evaluated as correct link

I wrote a small method that evaluates JSFiddle snippet URLs. A valid JSFiddle snippet URL looks like this: https://jsfiddle.net/BideoWego/y200sqpr/ or https://jsfiddle.net/BideoWego/y200sqpr. An invalid URL is anything else. It seems to work well, but for some strange reason it evaluates https://jsfiddle.net/…