Skip to content
Advertisement

Tag: regex

Capture word after first dot and before second dot

i have some strings like: I’m trying to write a regex that makes the first two string pass, but not the third one. The rule is that if the string contains the word “router” after the first dot and before the second dot it’s ok. i tried with but it match every .router. in my string, so also the third

How to scrape

so I am trying to figure out how I can possible scrape a javascript tag using regex which I believe might be the easiest way. The tag looks like: and I want to scrape all Label Whaht I tried to do is: but it only returned an empty value of [] so I am here asking what can I do

Processing and replacing text inside double curly braces

I have a URL string: var url = https://url.com/{{query}}/foo/{{query2}} I have a line of code that is able to take in a string, then get an array of all the queries inside the braces: var queries = String(url).match(/[^{}]+(?=})/g); Returns: queries = [‘query’, ‘query2’] I have a function, parse(queries), which processes these queries and returns a list of their results: results

Matching whole words that start or end with special characters

I need a regular expression in javascript that matches whole words that start or end with special characters? It was supposed to be easy, but for some reason b after ? doesn’t behave as I expected: What I need, for instance if my word is “FOO?” (including the question mark), I want to match: “FOO? is cool”, “do you think

Works in Chrome, but breaks in Safari: Invalid regular expression: invalid group specifier name /(?<=/)([^#]+)(?=#*)/

In my Javascript code, this regex /(?<=/)([^#]+)(?=#*)/ works fine in Chrome, but in safari, I get: Invalid regular expression: invalid group specifier name Any ideas? Answer Looks like Safari doesn’t support lookbehind yet (that is, your (?<=/)). One alternative would be to put the / that comes before in a non-captured group, and then extract only the first group (the

Regex windows path validator

I’ve tried to find a windows file path validation for Javascript, but none seemed to fulfill the requirements I wanted, so I decided to build it myself. The requirements are the following: the path should not be empty may begin with x:, x:\, , // and followed by a filename (no file extension required) filenames cannot include the following special

Advertisement