tagged [regex]

Negative matching using grep (match lines that do not contain foo)

Negative matching using grep (match lines that do not contain foo) How do I match all lines not matching a particular pattern using `grep`? I tried this:

14 Aug at 23:56

Regular Expression: Allow letters, numbers, and spaces (with at least one letter or number)

Regular Expression: Allow letters, numbers, and spaces (with at least one letter or number) I'm currently using this regex `^[A-Z0-9 _]*$` to accept letters, numbers, spaces and underscores. I need to...

12 Aug at 18:58

RegExp in TypeScript

RegExp in TypeScript How can I implement RegExp in TypeScript? My example:

4 Aug at 02:10

How can I validate an email address in JavaScript?

How can I validate an email address in JavaScript? I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent...

how to remove carriage returns, newlines, spaces from a string

how to remove carriage returns, newlines, spaces from a string How do I remove the spaces, carriage returns from in between `` ? I want the string result to end up as the following... ```

23 Jul at 13:40

RegEx to allow all characters, length should be 1-50 characters

RegEx to allow all characters, length should be 1-50 characters I am trying to implement a that will check a string is between 1 - 50 characters. They are allowed to enter any characters. I am new to ...

2 Jul at 13:52

Regex match any single character (one character only)

Regex match any single character (one character only) How do you match any one character with a regular expression? A number of other questions on Stack Overflow sound like they promise a quick answer...

2 Jul at 13:20

Limit length of characters in a regular expression

Limit length of characters in a regular expression Is there a way to limit a [regular expression](http://en.wikipedia.org/wiki/Regular_expression) to 100 characters a regular expression? So `Look at m...

2 Jul at 12:39

In Python, how do I split a string and keep the separators?

In Python, how do I split a string and keep the separators? Here's the simplest way to explain this. Here's what I'm using: Here's what I want: The reason is that I want to split a string into tokens,...

1 Jun at 12:1

Substring is not working as expected if length is greater than length of String

Substring is not working as expected if length is greater than length of String I know works, but I needed an alternative. I am using to capture the first 40 characters of a value. If the value at `A`...

20 May at 11:36

Regex.Split() on comma, space or semi-colon delimitted string

Regex.Split() on comma, space or semi-colon delimitted string I'm trying to split a string that can either be comma, space or semi-colon delimitted. It could also contain a space or spaces after each ...

6 May at 06:51

Regex (C#): Replace \n with \r\n

Regex (C#): Replace \n with \r\n How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#? I know to do it using plan `String.Replace`, like: However, thi...

22 Apr at 10:10

Regular expression to match balanced parentheses

Regular expression to match balanced parentheses I need a regular expression to select all the text between two outer brackets. Example: `START_TEXT(text here(possible text)text(possible text(more tex...

19 Apr at 12:33

Regular expression to extract numbers from a string

Regular expression to extract numbers from a string Can somebody help me construct this regular expression, please... Given the following strings... - - I need a regular expression that will extract t...

14 Apr at 12:11

What's the difference between "groups" and "captures" in .NET regular expressions?

What's the difference between "groups" and "captures" in .NET regular expressions? I'm a little fuzzy on what the difference between a "group" and a "capture" are when it comes to .NET's regular expre...

23 Mar at 03:39

How to search for occurrences of more than one space between words in a line

How to search for occurrences of more than one space between words in a line How to search for occurrences of more than one space between words in a line All the above are valid matches for this regex...

9 Mar at 17:2

Regex: match everything but a specific pattern

Regex: match everything but a specific pattern I need a regular expression able to match everything a string starting with a specific pattern (specifically `index.php` and what follows, like `index.ph...

23 Feb at 22:19

Trying to replace all white space with a single space

Trying to replace all white space with a single space My program is a file validation utility. I have to read in a format file and then parse out each line by a single space. But obviously, the person...

18 Feb at 20:5

Get string between two strings in a string

Get string between two strings in a string I have a string like: I want to just keep the string which is between `"key : "` and `" - "`. How can I do that? Must I use a Regex or can I do it in another...

18 Feb at 13:25

What is a good regular expression for catching typos in an email address?

What is a good regular expression for catching typos in an email address? When users create an account on my site I want to make server validation for emails to not accept input. I will send a confirm...

18 Feb at 06:48

How to match a newline character in a raw string?

How to match a newline character in a raw string? I got a little confused about Python raw string. I know that if we use raw string, then it will treat `'\'` as a normal backslash (ex. `r'\n'` would b...

15 Feb at 03:39

What is a non-capturing group in regular expressions?

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?

5 Jan at 21:38

Regular expression to validate valid time

Regular expression to validate valid time I need a regular expression to validate time. Valid values would be from `0:00` to `23:59`. When the time is less than `10:00` it should also support one char...

2 Dec at 06:18

How can I "inverse match" with regex?

How can I "inverse match" with regex? I'm processing a file, line-by-line, and I'd like to do an inverse match. For instance, I want to match lines where there is a string of six letters, but only if ...

1 Dec at 21:12

How can non-ASCII characters be removed from a string?

How can non-ASCII characters be removed from a string? I have strings `"A função"`, `"Ãugent"` in which I need to replace characters like `ç`, `ã`, and `Ã` with empty strings. How can I remove those n...

28 Nov at 05:46