Regex not start with. It only matches starting spaces .

Regex not start with Having a language in your question would help. Save & Share. For instance, the regex “^abc” denotes a string that begins with the word abc. awk # Script to join lines that does not start with 7 digits /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9]/ { print; next } { printf $0; getline; print } The pattern that you tried ^(?![^:]+:) means: assert that to the right of the current position there are not 1 or more characters other than : and then match :. Social Donate Info. For example if i want to retrieve all dots ". Note: Using . Match a string when the pattern exists except when starting with it. ls -d /proc/[^0-9]* All files recursively under /proc which do not start with a number:. Strings don't start with A or Space will match also the strings starts with hyphen -, so you don't need to specify the pattern for strings starting with hyphen. Exclude whitespace that is only comprised of tab characters in RegEx Pattern. * = zero or more of any character except newline m = enables multi-line mode, this sets regex to treat every line as a string, so ^ and $ will match start and end of line . regular expression not start with zero and be in a specified limit. A solution depends on how you want to use the test in your Perl code, but if you need an if statement then I would simply invert the test and check that the line doesn't start with == unless ( /^==/ ) or, if you're allergic to Perl's unless. Case sensitive. 17. *best). The engine looks for # before the first symbol after the start of string, and since there is no # before the start of string, any line is a match for . NET 8 (CS0177)? Can a rope thrower act as a propulsion I am trying to write a regex. So, let’s take a close look at each option. But the format can be different anytime. I have a regular expression that almost works: ^\S. It does so by allowing any word that does not start with w, or, if it starts with w it is either just that w or followed by a non-w and other stuff. Can use multi-line inline modifier (?m) (or RegexOptions. Using this, you can check, if there is at least one non-white-space character with ^\S+$. 7,832 6 6 gold Regular expression for not allowing alphabets at the start of string. Modified 12 years, 11 months ago. It will only match if the regex does not match. Regex to include one thing but exclude another. Save new Regex Start of string ^ End of string $ A word boundary \b. Regular expression to match any number NOT ending in zero. * followed by 0 or more characters By using that textbox, the user only can key in numeric. To allow this case, see the Option 2. * ^(?![A\s]). findall behaves weird - If you used ^ in the pattern to denote start of a line, not start of the whole string, or used $ to denote the end of a line and not a string, pass re. Bookmarks are cool, you could extract these lines by simply selecting to copy bookmarked Regex for strings not starting with "/*" 2. Make sure your regular expression starts with ^, which is a special character that represents the start of the string. Hot Network Questions Why an Out Parameter can be left unassigned in . function doesNotStartWithA (str) { return! /^A/. info for more details. Accept Words . For example, I want to capture {this} but not {my:monkey}. ] will match any 1 character which is not a period (. Improve this answer. 0. 3. I tried the following expression, but it does not work as expected, and the condition for COM does not work. Please help me. Thanks in advance! Skip to main content. You can exclude matching whitespace characters as well: ^(?![^:\s]+:) The reason ^(?<!# ). But not start with 0. Try this: /^stop. The caret ^ is the anchor that matches the beginning of a string in regular expressions. regex with tabs \t. regex starting with 07 and having 10 or 12 digits. match is false for. But the string containing whitespace(s) in the middle CAN match. Follow answered Jun You may use \R++(?!") to match 1+ line breaks that are not followed with a ". Regex to match specific strings without a given prefix. By utilizing REGEXP and RLIKE operators, developers can efficiently search, validate, and manipulate string data in more dynamic ways than simple LIKE queries. xt I came up with this. considering the first regex I gave, [^\s]+ means at least one not whitespace and \s+ means at least one white space. 15. te. regex101: match start of string that does not start with 'http' or is empty This is called negative lookahead. ^(?!git). I want to list the files which don't start with Simply bring up the find dialogue, type regex for lines not starting with digit ^\D. Another approach is to use [^A]. *[aeiouAEIOU]$' The idea of the regex is that ^[a-z] -> Have to start with a letter \w+$ -> can contain multiple alphanumeric characters (\w is the shortcut for [A-Za-z_]) Bear in mind the regex flags i for insensitive and m for multiline. matching string except spaces and tabs that follow. I want to use this to find string in VS 2013 IDE. [^. This will place blue circles, like marbles, in the left gutter - these are line bookmarks. This option matches strings that begin and end with a letter and ensures two -are not consecutive so a string like a--a is invalid. Regex to match between two lines. NET regular expressions, and probably a lot of other languages as well. Regex help for NOT expression. Since a word boundary looks for a spot where a word character (\w or [a-zA-Z0-9_]) is next to a non-word character (\W or [^a-zA-Z0-9_]), this means the example string _foo would not match (in between _ and f is not a word boundary). Typically, the caret “^” indicates that the match must start with the specified string. Note that it's very easy to see if something does start with a certain value, just use the anchor-to-first-start char '^'. EDIT: To those who came up with regexes using (?<!^) and then withdrew them because JavaScript doesn't support lookbehinds, that wasn't necessary. ]*$ That is zero or more characters that are not dots in the whole string. For example, this regex will check for all strings that start with 'abc' (followed by any \w character(s)): ^abc\w+ Regex to match a string not starting or ending with a pattern. 2. See perlre. I want to find (and replace with n Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/. Positive lookahead: This regex: ^[^. Improve this question. [^\s-] also works. However, I would like it to exclude a couple of string values such as /ignoreme and /ignoreme That is, not-not-whitespace (the capital S complements) or not-carriage-return or not-newline. * Breakdown: ^ beginning of line (?!git) not followed by 'git'. (ex: Hello. NET, Rust. ]+$ But this regex matches a number that starts with a dot too. Replace with an empty string. Regex: Not the beginning of a line? 26. *)) This matches strings that either do not start with j, or if they start with j there is not a u at the second position. Note also that parentheses groups together the second and third We can use look around regex in Vim to tackle this kind of question. golang regex to find urls in a string. If the multiline (m) flag is enabled, also matches immediately before a line break character. */[0-9]. Regular expressions, often referred to as regex or regexp, are a sequence of characters used to define a search pattern. However, the period/dot (. If you need this to be the case, add a secondary zero-length assertion using a lookbehind: I am looking for a regex which doesn't allow string to be started with either '!' or '='. If it's truly a word, bar that you don't want to match, then: ^(?!. ” To check if a string does not start with specific characters using a regular expression, use the test() function and negate it. By writing in single regular expression like SELECT DISTINCT CITY FROM STATION WHERE CITY NOT REGEXP '^[aeiouAEIOU]. --> should detect dot after "Hello" and at the end of the sentence but not in "@some. Viewed 18k times 10 . For instance, the regex ^abc Regex to match not start of line. So far i have tried below [^-\s][a-zA-Z0-9-_\\s]+$ Debuggex Demo. I need a regular expression that does not start with a dot or end with [-_. I'm trying to list files in a folder which don't start with a particular string. MULTILINE flag to re method, see Using ^ to match beginning of line in Python regex - If I have created a regex to match a phone number using the following one: ^[+0-9():. Regex remove leading zeros if string is number. Golang match domain names wild You may be thinking too literally about the last two requirements. We will explore different techniques, such as using the caret symbol, negative lookaheads, and the pipe symbol, to help you filter Regex NOT Operator. Hot Network Questions How bright is the sun now, as seen from Voyager? How manage inventory discrepancies due to measurement errors in warehouse management systems Straightening out a photo that was taken at an angle Can I buy a stock without owning it? How can I do In general it's a pain to write a regular expression not containing a particular string. But don't make the mistake of regarding this technique as a hack or a workaround; I would recommend this approach even if lookbehinds were available. Linus Use a regex that doesn't have any dots: ^[^. *$ and select Mark All. Python Regex for numbers Regex for strings not starting with "/*" Ask Question Asked 12 years, 11 months ago. *' -prune -o -print But this will also exclude numeric files in subdirectories (for example /proc/foo/bar/123). PCRE for PHP has several of these escape sequences. Excluding matches on the beginning or end of a line on a Regex with JavaScript. However, note that it DOES NOT consume characters. By the way, you don't have to use a regex. I came up with a need in a regular expression for finding numbers that do not start with COM. Hello Hello-World Hello_ Hello1 This works for . I suggest you to give a look at the filebeat's Supported Patterns. Apart from that the string should not end with a special character dot(. text text. Instead of specifying all the characters literally, you can use shorthands inside character classes: [\w] (lowercase) will match any "word character" (letter, numbers and underscore), [\W] (uppercase) will match anything but word They don't consume any character - the matching for regex following them (if any), will start at the same cursor position. Regex NOT or exclude match. Regular Expressions - Greedy but stop before a string match. [\p{L} . Help with regex include and exclude. Modified 5 years, 4 months ago. test(str); }. Non-word boundary \B. Regex("^[1-9][0-9]*$") return reg. M or re. Regex match strings not in certain brackets. Regex for not ending with specific words. Then, we are To check if a string does not start with specific characters using a regular expression, use the test() function and negate it. # any single character ) # end non-capturing group + # repeat previous match one or more times $ # match end of line/string a "literal text sequence" can in fact be a complex regular Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company You can use negated character classes to exclude certain characters: for example [^abcde] will match anything but a,b,c,d,e characters. This is the position where a word character is not followed or preceded by another Javascript regex for integer only, not to start with 0 but allow 0. Follow answered Nov 1, 2011 at 13:22. text te. I want my Regex expression to pick up the string having the word "best" and not the word "mew", i. So, if you wanted to match things that are not double-quotes, you would use [^"]; if you don't want to match any quotes, you could use [^"'], etc. That changes the meaning of ^ to mean the beginning of line as opposed to beginning of string (the default). Viewed 16k times 11 I'm trying to write a regex that will find all values between curly braces that do not begin with "my:". Nor do you need them in, say, Perl (when using an alternate delimiter as in The real problem is that filebeat does not support \d. If you can use look-around assertions, For example, how to tell if an input value does not start with 'abc'. Regular The GNU extensions to POSIX regular expressions use \` (backtick) to match the start of the string, and \' (single quote) to match the end of the string. The string that make it not work is ^@jj (basically anything that has ^ ). I have tried combining ^(. Related. Viewed 13k times 8 I need a regex to validate integer numbers. Javascript regex to validate if number begins with leading zero. Share. The ^ is an anchor which will instruct the regex engine to start matching from the very beginning of the string. Strings Ending with a Line Break Because Perl returns a string with a newline at the end when reading a line from a file, Perl’s regex engine matches $ at the position before the line break at the end of the string I know how to match 1-99, but do not get the 0 included. Regex "All that don't contain this string" regex to find files not starting from a particular string with list. Java regular expression for ending with * 0. RegEx for matching 7 digit numbers but not ones with a prefix. Metacharacters Inside Character Classes The hyphen can be included right after the opening bracket, or right before the closing bracket, or right after the negating caret. Make sure your regular expression starts with ^ , which is a special character that represents the start For example, how to tell if an input value does not start with 'abc'. {0,6}([^0-9]. The expression for things not containing "cat" was about 80 characters long. Regex exclude characters at start and end. Regular expressions and escaping special characters; regular-expressions. :) ( pls consider these two) Word can not start with _ (underscore) but may end with _ (underscore) For eg. . I don't care if it has a space in the "middle" just not at the beginning or the end. info/Character class. Follow edited Oct 13, 2011 at 12:36. thing is not working . It does not seem to work with non alphanumeric chars. ][\p{L} . What would be the best way to not match any characters now ? I was thinking of removing the \ but only doing this will transform the "not" into a "start with" Password should not start and end with special characters and special characters can be added between the string. It may have special characters, But it should not have consecutive special characters . Match the start of each new line with JavaScript regex. text. Ask Question Asked 10 years, 10 months ago. start with 1-9. *\bbar\b). For example, it is not necessary to escape / in regular expressions when using C#, because C# regular expressions are expressed (in part) as string literals. ), any number of times (*) $ means to the end of the line If you would like to enforce that stop be followed by a whitespace, you could modify the RegEx like Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company Visit the blog @Shafizadeh / is not a special character in regular expressions, only in languages where / is used to notate a literal regular expression. 11. files() Ask Question Asked 9 years, 4 months ago. Regular Expression to match a string, that doesn't end in a certain string. * subpattern. I have read similar questions but I can't get this to work. That is, for \s (white-space) there's its counter part \S (non-white-space). Text. Can anybody help me with this regex hell? Example: Hans Pedro (23123123) should be Hans Pedro. Regular expression for line match without specific word. Whitespace anywhere in the string will cause the regex to fail. Match strings which do not start or end with. Regular expression only one character and 7 numbers. ). Regex remove www from URL. *$ and ^((?!mew). )*$ Using grep in this case with -P option, which Interprets the PATTERN as a Perl regular expression. This means that if you add anything else past the ), it will start matching right away, even characters that were part of the negative lookahead. Regex should find substring that does not start with / 2. [RegularExpr Javascript regex to find words that do not start with "my:" Ask Question Asked 11 years, 5 months ago. 88. ^[^/]. RegularExpressions. If it starts with two w, then it must be either just that or followed by a non-w. How to set up REGEX that doesn't match anything? 0. Need to match strings which don't start with a given pattern using a regular expression in Python? If so, you may use the following syntax to find all strings except ones which don't start with https: r"^(?!https). Follow answered Oct 5, 2010 at 19:19. Anchor Starts With in Regular Expression. Regex to match all until blank line in Javascript. Note that \R matches any line break sequence (\r\n, \n or \r), ++ possessive quantifier matches 1 or more occurrences of (consecutive) line breaks while preventing any backtracking into the pattern, and only checks if there is no " after the last line Either use non-capturing groups, or re. *$/ Explanation: / charachters delimit the regular expression (i. Modified 12 years, 4 months ago. Allow: asd asd asd, asdasd, asd asd, Disallow: asd asdasd, asdasd, asdasd , I used this regex: ^[aeiou](\w|\s)*[aeiou]$ for words starting and ending with vowels and it works fine. Regular expression explanation: (?: group, but do not capture (0 or more Try this regular expression: ^([^j]. 5. Regex: match all special characters but not * 1. I want to use the regex for the Find-Replace Visual Studio tool that supports C# regular expressions. Note that it's very easy to see if something does start with a certain value, just use the anchor-to-first-start char Regular Expression to Only matches strings that do NOT start with a given string. 1. ][A-Za-z0-9]$ For example: test. [] denotes a set of characters to Input boundary end assertion: Matches the end of input. , the complementing ^ in the character class) with De Morgan’s law, this is equivalent to “whitespace but not carriage return or newline. REGEXP '^[^a-z0-9]' Or, use ^[^[:alnum:]], as POSIX character classes (like [:alnum:]) must be used inside The regex [^-\s] works as expected. But when I use this regex: ^[^aeiou](\w|\s)*[^aeiou]$ for words not starting and ending with vowels, it doesn't work. regular expression doesn't start with character A or whitespace ^(?![A\s]) To match the whole string, you need to add . The pattern that captures everything is: \{([^\}]*)\} I'm having trouble Then, we are going to illustrate how to find a string that does not start with a specific character. Using Caret ^ Anchor. EDIT: The regular expression you want is:-/^[a-zA-Z0-9](. Replace \d by [0-9] and your regular expression will work. 20. Regular expression for just 7 digits and 9 digits. Can you tell me what is wrong in my 2nd regex? Words are like: South Britain Rives Junction Larkspur The Weather Observation Station 12 question asks for city which don't start with a vowel AND don't end with a vowel. First, we will explain what the anchor ^ means. Some regex libraries I have used in the past had ways of getting an exact match. In that case you don't need the ^ and $. @some. Viewed 3k times Part of R Language Collective 3 . e. regex - Finding pattern which can contain character but not end with it (javascript)? 1. *[a-zA-Z0-9])?$/ Additional information. Regex for wildcard connected to string. In java you Regex matching everything that does NOT start with X OR contains Y. This fails if the string has only one char As per the requirement I need to generate a regex to match a String that doesn't start or end with space. It first ensures that it's not possible to match my at the start of the string, and then matches alphanumeric characters until the end of the string. As per my understanding I've generated a regex "\\S(. for showing space in examples. The brackets, [], denote a character set and if it starts with a ^ that means "not this character set". Your pattern does not work because of doubled brackets. Regex Editor Community Patterns Account Regex Quiz Settings. But what if you want to find lines of code that don't contain a specific word? In this article, you will learn how to use regular expressions to exclude or negate matches. Follow Perl (and other languages) allows for constructing really complicated-looking regular expressions that allows you to do exactly what you need to do in one big blobby-regex (or, as it may well be, with a short and snappy crypto-regex), but for the sake I need a regex to find all chars that are NOT a-z or 0-9 I don't know the syntax for the NOT operator in regex. ]+$ should match what you are after. Read regular-expression. I'm trying but I can't seem to get it. match is true for. Is Java ^ = start of line CTR = literal CTR $ = end of line. * does NOT discriminate between # comment and not a comment is that (?<!#) checks the text before the current position. Match regex that doesn't start with something. Then just select from main menu Search -> Bookmark -> Remove bookmarked lines. The condition is that it shouldn't start nor end with a forward slash (/). AGuyCalledGerald. finditer, or remove redundant capturing groups, see re. – In MySQL, regular expressions (REGEX) are a powerful tool used to perform flexible pattern matching within string data. followed by * means match any character (. It only matches starting spaces Python regular expression to check start string is present or not. My regular expression for 1-99 is ^[1-9][0-9]?$ regex; Share. * OR ^[^A\s]. Modified 4 years, 11 months ago. Regex reg = null; reg = new System. If it's alphanumeric (so. Edit: I just finished and yes, it's: Regex not start with dot or end with dot. My usecase is to modify the above regex such that it matches a number that doesnt starts with a dot but contians a dot. *" Causes ^ and $ to match the begin/end of each line (not only begin/end of string) Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, In this short tutorial, we are going to cover in-depth the anchor starts with to match the start of a string using regex. Stack Overflow. ]+ will match one ore more characters which is either a letter (in any language as shown here), a white space or a period. ^[a-z]+(?:-?[a-z]+)+$ ^ Assert position at the start of the line [a-z]+ Match any lowercase ASCII letter one or more times (with i flag this also matches uppercase variants) (?:-?[a-z]+)+ Match the I need a regular expression that makes sure a string does not start with or end with a space. In regex, the ! does not mean negation; instead, you want to negate a character set with [^"]. ]*[^-_. Simply put, regular expressions don’t provide a built-in not operator. *\Z/m The regular expression which matches strings that do not begin with 7 digits is very simple:. regex to allow "single 0" or " any other number of digits? 1. About; Products OverflowAI; At start [^a-zA-Z0-9] for condition; pre_match(); pre_replace(); ergi(); try this. However, we can mimic its behavior using several workarounds. Ask Question Asked 12 years, 4 months ago. Regex - match all that don't have / 0. I am trying to look for a regular expression which does not start with // I tried Google but no luck. asked Oct 13 How to ignore digits that start with 0 (zero) using regular expression? 0. * DEMO. Viewed 14k times 5 What regex Regular expression for a string that does not start with a /* 2. This regex works but fails for the first condition; it does not start with dot: ^[A-Za-z0-9][^. ]. *|j($|[^u]. So, it ends up being I am looking for regular expression that allow strings that does not start and does not end with white-space and does not consist of few white-spaces in a row. With Notepad++, you should be RegEx start with, contains these, not end with? 1. In this article, we will explain how to use SQL regular expressions, cover This should work: ^[^\s]+(\s+[^\s]+)*$ If you want to include character restrictions: ^[-a-zA-Z0-9-()]+(\s+[-a-zA-Z0-9-()]+)*$ Explanation: the starting ^ and ending $ denotes the string. find /proc -regex '. Regex expression for patterns that don't begin with numbers python. after the user key in the 1-9 at the first character, the user can key in 0. *$ The above will match any string that does not contain bar that is on a word boundary, that is to say, separated from non-word characters. All files and directories in /proc which do not contain numbers (in other words, excluding process directories):. For example, /t$/ does not match the "t" in "eater", but does match it in "eat". Regex start with any I need a regular expression that accepts everything except numbers and (& ). Regex expression to match tab. If you want to exclude only the top-level I am trying to construct regular expression in pythond for following rules, Accept Words containing only alphabets; Words may contain - ( hypen) word can not end with special character, for eg. I tried using the below regex but was not successful. Regex: Everything except some pattern. Here i have the regular expression that should not allow user to not enter string's starting character and ending character with special Note the anchor to start of input ^ which is required to make it work. Regular expression with only numbers after it. a-z and 0-9, right?) then saying "dont allow numbers or underscore at the start" is probably the same as "must start with a letter" ^[a-z][a-z0-9_]*$ This is "must start with a-z", followed by "must follow with zero or more letters, numbers or underscores. *\\S)?$" which restrict the string that has a space at the beginning and at the end of the string. Distributing the outer not (i. Regular expressions are a powerful tool for matching patterns in code. Steve Emmerson Steve Emmerson. IsMatch(str); That is my regex expression. Going to ignore block comments ? Ok, this ^\s* might be bad because \s can span lines. Before diving into the specifics of the regex not operator, it is essential to have a basic understanding of regular expressions. Regex exclude criteria. Multiline). python3 regex match pattern but only if it does not end in certain character. NET 6 but not . *\S$ Here are some example results: "HELLO" (Match) "HEL LO" (Match) " HELLO" (No Match) "HELLO " (No Match) "H" (No Most regular expression engines support "counter part" escape sequences. *[^/]$ is the one I have been trying with. if I have a regular expression as follows: ^/[a-z0-9]+$ This matches strings such as /hello or /hello123. You can fix your pattern using. . Regex from special characters "/*" to "*/" 2. See also. JavaScript match The regex matches one or more of any character except digits or commas, after making sure the first character isn't a hyphen at the beginning of the string. 4. Regular Expressions 101. Also, be sure you've used ^, it stands for the start of the string. I want the regex to be NOT [a-z, A-Z, 0-9]. thing"). String: //debugger; debugger; <--regex should match only this, rest has to ignore // debugger; /// debugger; Option 1. they are not part of the Regex per se) ^ means match at the beginning of the line. xt. com should be a valid Since the OP is looking for a general regex and not specially for grep, this is the general regex for lines not starting with "git". Help With Particular Regular Expression - Not Containing Some String. You get no right replacement for the strings like 1 : A because the negated character class [^:] also matches a whitespace char. Regular expression to not match "www" 4. Hot Network Questions Why must Grassmann algebras for The problem with that is that it does not match characters as planned but for one match it does work. " except in the words starting with "@". I can use 2 regexes if needed. Using regex to trim trailing white space. Here is my code at the moment in which I have only added the code for '=' which doesn't work. Above is not allowing whitespace(s) at the beginning, but also not allowing in the middle/end of the string. regex; It will start from the beginning of the string (^) and match one or more characters which are not a digit (\d) There's no "not" operator in Java regular expressions like there is in Perl. While in multi-line mode you can still match the start and end of the string with \A\Z permanent anchors /\ACTR. We had to do this for models of computation - you take an NFA, which is easy enough to define, and then reduce it to a regular expression. Regular Expression * | 0. I would like to have a regex which matches the string with NO whitespace(s) at the beginning. ) used in the above pattern will not match newline characters unless the correct regex flag is used: The Basics of Regular Expressions. So, it matches a] at the start of a string. \b: Word boundary assertion: Matches a word boundary. Regex to match pattern only if the line does not start with a character. how to negate any regular expression in Java. Modified 9 years, 4 months ago. I'm not an expert on regex. In regular expressions ^ means 'beginning of string' and $ means 'end of string', so for example:-/^something$/ Matches 'something' But not 'This is a string containing something and some other stuff' You can negate characters using [^-char to Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/. If I understand you correctly, you want to search a line not starting with 2021, right? The following search pattern works: /\v^(2021)@! A teardown of this search: \v: use magic search, which will simplify the vim regex, see also :h \v. *)? A more classic regex equivalent without {} syntax is actually more readable: it visually shows us what is going on: $ cat seven. ^[[a-z|0-9]] matches the start of string (^) position, then [[a-z|0-9] match a [, or an ASCII letter, or |, or an ASCII digit, and then a ]. e the first and third string. Regex match where part of string doesn't contain a (?x) # enable regex comment mode ^ # match start of line/string (?: # begin non-capturing group (?! # begin negative lookahead ab # literal text sequence ab ) # end negative lookahead . Python Regex: don't match if containing some string. See if Dot-net supports horizontal whitespace \h if not [^\S\r\n] works also. ^: matches start of a line The <-- HERE shows whereabouts in the regular expression the problem was discovered. Breaking it down: ^ : start of string [ : beginning of character group a-z : any lowercase letter A-Z : any uppercase letter 0-9 : any digit _ : underscore ] : end of character group * : zero or more of the given characters $ : end of string If you don't want to allow empty strings, use + instead . Thus, when the \n in the regex does match a newline, you know it's not inside a <pre> element, and should be replaced with a <p/>. Finally, the $ will Regex match tabs that are not at the start of the line. Regular expression to match anything that doesn't contain '/' 0. I need a regex to not match strings starting and/or ending with space(s) but matching in between spaces. pbp kijtw cqomj iida pjk exj khcn bsthtxjx hswl buevns