Top "Regex" questions

Regular expressions provide a declarative language to match patterns within strings.

How do you access the matched groups in a JavaScript regular expression?

I want to match a portion of a string using a regular expression and then access that parenthesized substring: var …

javascript regex
Regex to check whether a string contains only numbers

hash = window.location.hash.substr(1); var reg = new RegExp('^[0-9]$'); console.log(reg.test(hash)); I get false …

javascript regex
Split string on whitespace in Python

I'm looking for the Python equivalent of String str = "many fancy word \nhello \thi"; String whiteSpaceRegex = "\\s"; String[] words = str.…

python regex string split whitespace
Regex to match only letters

How can I write a regex that matches only letters?

regex language-agnostic letter
How can I exclude one word with grep?

I need something like: grep ^"unwanted_word"XXXXXXXX

regex string search grep
Regex: ignore case sensitivity

How can I make the following regex ignore case sensitivity? It should match all the correct characters but ignore whether …

regex
What is a non-capturing group in regular expressions?

How are non-capturing groups, i.e. (?:), used in regular expressions and what are they good for?

regex capturing-group regex-group
Using String Format to show decimal up to 2 places or simple integer

I have got a price field to display which sometimes can be either 100 or 100.99 or 100.9, What I want is to …

c# regex string-formatting number-formatting
How to negate specific word in regex?

I know that I can negate group of chars as in [^bar] but I need a regular expression where negation …

regex
What is a good regular expression to match a URL?

Currently I have an input box which will detect the URL and parse the data. So right now, I am …

javascript regex