Skip to content
Advertisement

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: qwertyabababababababababababa to become: qwertyab11a Similarly, a a a

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 required) b – 8 alphanumeric characters c – 4 alphanumeric characters d – 4 alphanumeric characters e – 4 alphanumeric

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 numbers in the username have to be at the

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? Answer Try this one instead: It matches a

Regex match first character once, followed by repetitive matching until end

I’m trying to match characters that shouldn’t be allowed in a username string to then be replaced. Anything outside this range should match first character [a-zA-Z] <– restricting the first character is causing problems and I don’t know how to fix it And then match everything else outside this range [0-9a-zA-Z_.] <—- repeat until the end of the string Matches:

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/BideoWego/ to true. How can I fix this. Answer My solution is if the last character is / then remove it

Advertisement