Skip to content
Advertisement

Tag: regex-group

Is it possible to use only lookaround to match characters that are not repeated immediately before and after?

For example, to match the first slash after the domain name in the URL. Intent: Only match ‘/’ in ‘.com/…’ but not any ‘/’ in ‘https://’. The above [A] returns the correct match, but [B] is the kind of expression I want (although it did not match any characters), that is, to use the / character only 1 time in

JavaScript: How to reduce IFs with REGEX

I’m working on the following function which I had to add a few IFs in case the string was shorter than the format the REGEX groups was expecting: Is there a way to remove the IFs and get the same output with just Regex? I’m looking for something like: complete: 999.999.999-99 partial: 999.999.9 Because the function will be called when

Regex pattern for extraction of double-quoted and non-quoted strings Javascript

im desperately trying to extract double quoted and non-quoted words from following string (Please note the single quotes around): Desired groups are: “Cloud Technology” Foundation “Board” I came up with this pattern (?:”(.*?)”)|(?:s(S*?)s) have a look in regex101.com But the pattern doesnt works if the string would be for example ‘”Cloud Technology” Foundation’ Answer You can use See the regex

How to extend regex to accept @ in image urls

I have a regex for validating image urls, however some of the images are using @ for example: https://test.com/image-name@2x.jpeg. How can I extend this regex to accept also the @ character inside of the image link? Current regex look like this Answer If it can only be part of the image name, you can add a forward slash followed by

Advertisement