Skip to content
Advertisement

Tag: regex

Regex – Replace quote in quotes

The following regex pattern finds the a single double quote in the following string examples (basically the double quote after the 1). The problem is that the positive lookbehind is not supported in some browsers. Is there an alternative regex pattern that would work? I need to replace this double quote with another character using js (eg with a ?

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

Javascript get the value of an href after a certain pattern

I have a url like https://www.whatever.com/en-CA/something I want to capture anything that comes after the en-CA/ (the en-CA can be any combination of characters that have two letters, a dash, and two letters. I am trying to use a regex to grab the window.location.href split the href at the pattern that matched the /en-CA/ take the remainder of the href

Regex to match string in a sentence

I am trying to find a strictly declared string in a sentence, the thread says: Find the position of the string “ten” within a sentence, without using the exact string directly (this can be avoided in many ways using just a bit of RegEx). Print as many spaces as there were characters in the original sentence before the aforementioned string

Filtering files in directory with regex.match using Puppeteer

I’m having issues with regex.match not matching filenames which do match when I test them individually in an online checker https://regex101.com Can anyone spot the problem in code below? Q: Should I be using regex.test instead of match? If yes, how do I create the regex when it contains variables? It should match all files starting with: ES_(Stay) True –

Advertisement