Tag Archives: regex

find link in string html with regex

Questions: i need to find all links in html string only in href on both cases of double qute(“”) or single qute(”) example: <a href=’text’> or <div href=”text”>; i came up with function findHrefValues(str) { let hrefs = []; let pattern = /href='([^’]+)’/g; let match = pattern.exec(str); if(match && Array.isArray(match)) { match.forEach((href)=> { if(href) hrefs.push(href);… Read More »

Javascript Regex – to fetch specific html tag from a string of tags

Questions: I have a string which contains HTML TD tags. I want to construct a regex to fetch that TD which has innerHTML “Number” Example: Following are the whole string var rows = `<td width=”69″ style=”white-space:normal”>Name</td> <td width=”70″ style=”white-space:normal;border-left:none”>Number</td> <td width=”64″ style=”white-space:normal;border-left:none”>Type</td>`; Regex should be: If I put “Number” in regex, second TD tag should… Read More »

Navigation Hirearchy Regex level matches Gonative.io

Questions: I am using Gognitive.io to create my mobile apps I have enabled Navigation hierarchy, that allows matching the URL levels using regular expressions. After trying many times, I have been failed to match the URLs using regular expressions (Regex) I try to match the level like this [ { “regex”: “https://example.com/?”, “level”: 1 },… Read More »

Regex to detect smart-alec spaces in words(!)

Questions: I am trying to create a regex that will stop the “forget” word.. Smart alecs are still getting away with: “f o r g e t you”, and “f o r g e t you” (using \r\n) Before I captured the offending word with $(?<!(FORGET[\s]*)) I am attempting to use $(<!(F\s*O\s*R\s*G\s*E\s*T)) – with the… Read More »

Navigation Hirearchy Regex level matches Gonative.io

Questions: I am using Gognitive.io to create my mobile apps I have enabled Navigation hierarchy, that allows matching the URL levels using regular expressions. After trying many times, I have been failed to match the URLs using regular expressions (Regex) I try to match the level like this [ { “regex”: “https://example.com/?”, “level”: 1 },… Read More »

Regex to split a string in C#

Questions: I have a string input like: var input = “1. J. Carter 2. Mark R. 1000. Axl” There can be any number of names, but the point is that I need to split this string in an array like this J. Carter Mark R. Axl I think there should be a way to do… Read More »

Regex to ignore parentheses while capturing within parentheses

Questions: I am parsing a file in javascript & have to capture some values. For example velocity values as below. Eg: > “velocity(22)”.match(“\\(([^()]*)\\)”); [ ‘(22)’, ’22’, index: 8, input: ‘velocity(22)’ ] Above works fine and 22 gets captured in match[1]. Problem is when the values have units mentioned in parantheses. Eg: > “velocity(22 (m/s))”.match(“\\(([^()]*)\\)”); [… Read More »