regex-negation

Negate match for word in the beginning of string in RE2 syntax?

女生的网名这么多〃 提交于 2019-12-02 02:23:58
Let's say that I have following strings: mail to tel:+358123456 http://www.google.fi mailto:foo@bar.fi hello world telephone elephant penny link owl How can I find only strings that do not start with 'tel:', 'http://' and 'mailto:' in RE2 syntax? I've tried following with following syntax, but it filters out all of them: [^(https?://|tel:|mailto:)] edit: RE2 syntax does not support negative lookbehind/lookahead. There is no drop-in workaround for the lack of negative lookbehind on RE2 that I know of. Why don't you match on strings that do start with those keywords instead? Then you can dismiss

Matching patterns in Python

坚强是说给别人听的谎言 提交于 2019-12-02 02:20:39
I have an XML file which contains the following strings: <field name="id">abcdef</field> <field name="intro" > pqrst</field> <field name="desc"> this is a test file. We will show 5>2 and 3<5 and try to remove non xml compatible characters.</field> In the body of the XML, I have > and < characters, which are not compatible with the XML specification. I need to replace them such that when > and < are in: ' "> ' ' " > ' and ' </ ' respectively, they should NOT be replaced, all other occurrence of > and < should be replaced by strings "greater than" and "less than". So the result should be like:

replace characters in notepad++ BUT exclude characters inside single quotation marks

戏子无情 提交于 2019-12-01 23:24:25
I have a string in this kind: SELECT column_name FROM table_name WHERE column_name IN ('A' , 'stu' ,'Meyer', ....); I want replace all characters in notepad++ from upper to lower (or vice versa) BUT, exclude from replacement, characters inside single quotation marks. condition: It exists no solid structure before/behind the single quotation marks part! (That means - I can not use the keyword "IN" or signs like "," or "(" or ")" or ";" for this regex ...!) target string (the characters inside single quotation marks have to stay unchangend): select column_name from table_name where column_name

Regex inverse matching on specific string?

北慕城南 提交于 2019-12-01 20:53:56
问题 I would like to match the following com.my.company. moduleA .MyClassName com.my.company. moduleB .MyClassName com.my.company. anythingElse .MyClassName but not the following com.my.company. core .MyClassName My current simple regex pattern is : Pattern PATTERN_MODULE_NAME = Pattern.compile("com\\.my\\.company\\.(.*?)\\..*") Matcher matcher = PATTERN_MODULE_NAME.matcher(className); if (matcher.matches()) { // will return the string inside the parentheses (.*?) return matcher.group(1); } So,

Regex inverse matching on specific string?

99封情书 提交于 2019-12-01 19:03:08
I would like to match the following com.my.company. moduleA .MyClassName com.my.company. moduleB .MyClassName com.my.company. anythingElse .MyClassName but not the following com.my.company. core .MyClassName My current simple regex pattern is : Pattern PATTERN_MODULE_NAME = Pattern.compile("com\\.my\\.company\\.(.*?)\\..*") Matcher matcher = PATTERN_MODULE_NAME.matcher(className); if (matcher.matches()) { // will return the string inside the parentheses (.*?) return matcher.group(1); } So, basically, how can i match everything else, but not a specific string, which is the string core in my

Regex for “Does not contain four or more repeated characters”

旧时模样 提交于 2019-12-01 10:50:11
My experience with regular expressions is limited and I've been reading various tutorials and posts on negation and negative lookahead, etc, but nothing seems to quite match my situation. I'm trying to create an attribute in ASP.NET MVC3 for password complexity. Part of the validation includes a minimum number of repeated characters. For the current project the limit is 3, but I want to generalize it. Initially, I was using @"(.)\1{3,}" to test for 4 or more repeated characters and then negating that result. I can't do that now because I need to create a ModelClientValidationRegexRule object,

Select the next line after match regex

自作多情 提交于 2019-12-01 08:11:56
I'm currently using a scanning software "Drivve Image" to extract certain information from each paper. This software enables certain Regex code to be run if needed. It seems to be run with the UltraEdit Regex Engine. I get the following scanned result: 1. 21Sid1 2. Ordernr 3. E17222 4. By 5. Seller I need to search the string for the text Ordernr and then pick the following line E17222 which in the end will be said filename of the scanned document. I will never know the exact position of these two values in the string. That is why I need to focus on Ordernr because the text I need will always

Regex for “Does not contain four or more repeated characters”

梦想的初衷 提交于 2019-12-01 08:07:37
问题 My experience with regular expressions is limited and I've been reading various tutorials and posts on negation and negative lookahead, etc, but nothing seems to quite match my situation. I'm trying to create an attribute in ASP.NET MVC3 for password complexity. Part of the validation includes a minimum number of repeated characters. For the current project the limit is 3, but I want to generalize it. Initially, I was using @"(.)\1{3,}" to test for 4 or more repeated characters and then

Select the next line after match regex

倾然丶 夕夏残阳落幕 提交于 2019-12-01 06:42:14
问题 I'm currently using a scanning software "Drivve Image" to extract certain information from each paper. This software enables certain Regex code to be run if needed. It seems to be run with the UltraEdit Regex Engine. I get the following scanned result: 1. 21Sid1 2. Ordernr 3. E17222 4. By 5. Seller I need to search the string for the text Ordernr and then pick the following line E17222 which in the end will be said filename of the scanned document. I will never know the exact position of

Regex to match a whole string only if it lacks a given substring/suffix

孤人 提交于 2019-12-01 03:48:23
I've searched for questions like this, but all the cases I found were solved in a problem-specific manner, like using !g in vi to negate the regex matches, or matching other things, without a regex negation. Thus, I'm interested in a “pure” solution to this: Having a set of strings I need to filter them with a regular expression matcher so that it only leaves (matches) the strings lacking a given substring. For example, filtering out "Foo" in: Boo Foo Bar FooBar BooFooBar Baz Would result in: Boo Bar Baz I tried constructing it with negative look aheads/behinds (?!regex) / (?<!regex) , but