Split a string between special characters [closed]

Use a regular expression with a capture group and RegEx.exec() to extract any substrings between three apostrophes. The pattern uses lazy matching (.*?) to match any sequence of characters (including none) between the apostrophes. const str = ” My random text ”’tag1”’ ”’tag2”’ “; re = /”'(.*?)”’/g; matches = []; while (match = re.exec(str)) { … Read more

Regular Expression for name

I think what you are trying to know is the generic regular expression which starts with any alphabets and has only alpha-numeric characters in it. Look, the generic format (in java, for string pattern matching) for your query is this: String pattern = “[a-zA-Z][a-zA-Z0-9]*”; or String pattern = “[a-zA-Z](\\w)*”; represents kleene star operator which denotes … Read more

Regex extracting price or number value from string in JavaScript [duplicate]

You can use the following regex: -?\d+(?:,\d{3})*(?:\.\d+)? It matches an optional hyphen (-?), then 1 or more digits (\d+), then optional 3-digit groups ((?:,\d{3})*), then an optional decimal part ((?:\.\d+)?). var s = “hello-sdvf-1,234.23 23 everybody 4”; var res = s.match(/-?\d+(?:,\d{3})*(?:\.\d+)?/); document.getElementById(“r”).innerHTML = res; <div id=”r”/> Or, to match multiple values: var re = /-?\d+(?:,\d{3})*(?:\.\d+)?/g; … Read more