lookbehind

Syntax for Lookahead and Lookbehind in Grok Custom Pattern

回眸只為那壹抹淺笑 提交于 2019-12-11 14:40:12
问题 I'm trying to use a lookbehind and a lookahead in a Grok custom pattern and getting pattern match errors in the Grok debugger that I cannot resolve. This is for archiving system logs. I am currently trying to parse the postgrey application. Given data such as: 2019-04-09T11:41:31-05:00 67.157.192.7 postgrey: action=pass, reason=triplet found, delay=388, client_name=unknown, client_address=103.255.78.9, sender=members@domain.com, recipient=person@domain.com I'm trying to use the following to

Javascript regexp that matches '.' not preceded by '\' (lookbehind alternative)

你。 提交于 2019-12-11 06:33:22
问题 I am making a (Excel like) number formater function in javascript. I want to use templates like "0 000.00" and "000.000.000" which would produce: format(123456789,"0 000.00") >> "123 456 789.00" format(123456789,"000\.000\.000") >> "123.456.789" So I need to match '.' not preceded by '\'. Since there is no lookbehind in javascript, what would be the regexp for splitting the whole and decimal part of a template? This unfortunately doesn't work :-( template.split(/(?<!\\)\./); 回答1: Reverse the

Perl Regex: How to remove quotes inside quotes from CSV line

亡梦爱人 提交于 2019-12-10 18:34:47
问题 I've got a line from a CSV file with " as field encloser and , as field seperator as a string. Sometimes there are " in the data that break the field enclosers. I'm looking for a regex to remove these " . My string looks like this: my $csv = qq~"123456","024003","Stuff","","28" stuff with more stuff","2"," 1.99 ","",""~; I've looked at this but I don't understand how to tell it to only remove quotes that are not at the beginning of the string not at the end of the string not preceded by a ,

Replace all “\” characters which are *not* inside “<code>” tags

二次信任 提交于 2019-12-10 16:25:52
问题 First things first: Neither this, this, this nor this answered my question. So I'll open a new one. Please read Okay okay. I know that regexes are not the way to parse general HTML. Please take note that the created documents are written using a limited, controlled HTML subset. And people writing the docs know what they're doing. They are all IT professionals! Given the controlled syntax it is possible to parse the documents I have here using regexes. I am not trying to download arbitrary

Regex PHP. Reduce steps: limited by fixed width Lookbehind

若如初见. 提交于 2019-12-08 02:38:18
问题 I have a regex that will be used to match @users tags. I use lokarround assertions, letting punctuation and white space characters surround the tags. There is an added complication, there are a type of bbcodes that represent html. I have two types of bbcodes, inline ( ^B bold ^b ) and blocks ( ^C center ^c ). The inline ones have to be passed thru to reach for the previous or next character. And the blocks are allowed to surround a tag, just like punctuation. I made a regex that does work.

Regex PHP. Reduce steps: limited by fixed width Lookbehind

天涯浪子 提交于 2019-12-06 04:44:24
I have a regex that will be used to match @users tags. I use lokarround assertions, letting punctuation and white space characters surround the tags. There is an added complication, there are a type of bbcodes that represent html. I have two types of bbcodes, inline ( ^B bold ^b ) and blocks ( ^C center ^c ). The inline ones have to be passed thru to reach for the previous or next character. And the blocks are allowed to surround a tag, just like punctuation. I made a regex that does work. What I want to do now is to lower the number of steps that it does in every character that’s not going to

Nested regex lookahead and lookbehind

南笙酒味 提交于 2019-12-05 18:28:51
问题 I am having problems with the nested '+'/'-' lookahead/lookbehind in regex. Let's say that I want to change the '*' in a string with '%' and let's say that '\' escapes the next character. (Turning a regex to sql like command ^^). So the string '*test*' should be changed to '%test%' , '\\*test\\*' -> '\\%test\\%' , but '\*test\*' and '\\\*test\\\*' should stay the same. I tried: (?<!\\)(?=\\\\)*\* but this doesn't work (?<!\\)((?=\\\\)*\*) ... (?<!\\(?=\\\\)*)\* ... (?=(?<!\\)(?=\\\\)*)\* ...

Quantifier range not working in lookbehind

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:45:29
Okay so I'm working on a project where I need a regex that can match a * followed by 1-4 spaces or tabs and then followed by a row of text. Right now I'm using .* after the lookbehind for testing purposes. However I can get it to match explicitly 1, 2, or 4 spaces/tabs but not 1-4. I'm testing against the following block * test line here * Second test * Third test * Another test And these are the two patterns I'm testing (?<=(\*[ \t]{3})).* which works just as expected and matches the 2nd line, same if I replace 3 with 1, 2 or 4 however if I replace it with 1,4 forming the following pattern (?

Regular Expression - Match all but first letter in each word in sentence

浪子不回头ぞ 提交于 2019-12-04 10:56:35
I've almost got the answer here, but I'm missing something and I hope someone here can help me out. I need a regular expression that will match all but the first letter in each word in a sentence. Then I need to replace the matched letters with the correct number of asterisks. For example, if I have the following sentence: There is an enormous apple tree in my backyard. I need to get this result: T**** i* a* e******* a**** t*** i* m* b*******. I have managed to come up with an expression that almost does that: (?<=(\b[A-Za-z]))([a-z]+) Using the example sentence above, that expression gives me

Nested regex lookahead and lookbehind

僤鯓⒐⒋嵵緔 提交于 2019-12-04 02:53:44
I am having problems with the nested '+'/'-' lookahead/lookbehind in regex. Let's say that I want to change the '*' in a string with '%' and let's say that '\' escapes the next character. (Turning a regex to sql like command ^^). So the string '*test*' should be changed to '%test%' , '\\*test\\*' -> '\\%test\\%' , but '\*test\*' and '\\\*test\\\*' should stay the same. I tried: (?<!\\)(?=\\\\)*\* but this doesn't work (?<!\\)((?=\\\\)*\*) ... (?<!\\(?=\\\\)*)\* ... (?=(?<!\\)(?=\\\\)*)\* ... What is the correct regex that will match the '*'s in examples given above? What is the difference