rubular

Logstash Fork Patterns 中文

╄→尐↘猪︶ㄣ 提交于 2020-07-25 09:57:05
前情提要 1.产品增加了日志字段 ,其中包含中文,相应的fork patterns也需要修改 Patterns # Grok Pattern %{NOTSPACE:resp_msg} # Custom Patterns NOTSPACE \S* 测试工具以及参考链接 a Ruby regular expression editor logstash grok-patterns 来源: oschina 链接: https://my.oschina.net/venn0126/blog/4354770

Regex for huge string

冷暖自知 提交于 2019-12-24 13:34:14
问题 I have the below string: "\n - MyLibrary1 (= 0.10.0)\n - AFNetworking (= 1.1.0)\n - MyLibrary2 (= 3.0.0)\n - Objective-C-HMTL-Parser (= 0.0.1)\n\n" I want to create a JSON like this: { "MyLibrary1": "0.10.0", "AFNetworking": "1.1.0", "MyLibrary2": "3.0.0", "Objective-C-HMTL-Parser": "0.0.1" } For which I need to separate "MyLibrary1" and "0.10.0" and similarly other data to create a string. I am working on a regex to separate data from the string. I tried /-(.*)/ and /=(.*)/ but this returns

regular expression ruby phone number

白昼怎懂夜的黑 提交于 2019-12-24 03:25:23
问题 I'm trying to figure out how to write my own regex. I made a list of viable phone numbers and non-viable ones and trying to make sure the viable ones are included but I can't figure out how to finish it up. Allowed list 0665363636 // 06 65 36 36 36 // 06-65-36-36-36 // +33 6 65 36 36 36 Not allowed 06 65 36 36 // 2336653636 // +3366536361 // 0065363636 I messed around with it a bit and I currently have this: [0+][63][6 \-3][56\ ][\d{1}][\d \-]\d{2}[\d{1} \-]\d\d? ?\-?\d?\d? ?\d?\d?$ This

Regex to match a String with optional Conditions [duplicate]

自古美人都是妖i 提交于 2019-12-24 01:44:49
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How do I make part of a regular expression optional in Ruby? I'm trying to build a regular expression with rubular to match: On Feb 23, 2011, at 10:22 , James Bond wrote: OR On Feb 23, 2011, at 10:22 AM , James Bond wrote: Here's what I have so far, but for some reason it's not matching? Ideas? (On.* (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2}, [12]\d{3}.* at \d{1,2}:\d{1,2} (?:AM|PM),.*wrote:)

REGEX - Matching again multiple lines

徘徊边缘 提交于 2019-12-11 17:54:18
问题 Given text like: XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX.XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX.XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. XXXXXXX. Boss: asdasdasdasd Date: XXX, XXXXXXXXX I want to match the last 3 lines: Here's what I'm trying but it's failing: ^Boss:.*$^Date:.*$ Suggestions? Thanks 回答1: You might need to skip the first x lines... also you anchor ^ is probably

Regex, how to match multiple lines?

折月煮酒 提交于 2019-11-28 08:51:43
I'm trying to match the From line all the way to the end of the Subject line in the following: .... From: XXXXXX Date: Tue, 8 Mar 2011 10:52:42 -0800 To: XXXXXXX Subject: XXXXXXX .... So far I have: /From:.*Date:.*To:.*Subject/m But that doesn't match to the end of the subject line. I tried adding $ but that had no effect. Pan Thomakos You can use the /m modifier to enable multiline mode (i.e. to allow . to match newlines), and you can use ? to perform non-greedy matching: message = <<-MSG Random Line 1 Random Line 2 From: person@example.com Date: 01-01-2011 To: friend@example.com Subject:

Regex, how to match multiple lines?

青春壹個敷衍的年華 提交于 2019-11-26 20:52:03
问题 I'm trying to match the From line all the way to the end of the Subject line in the following: .... From: XXXXXX Date: Tue, 8 Mar 2011 10:52:42 -0800 To: XXXXXXX Subject: XXXXXXX .... So far I have: /From:.*Date:.*To:.*Subject/m But that doesn't match to the end of the subject line. I tried adding $ but that had no effect. 回答1: You can use the /m modifier to enable multiline mode (i.e. to allow . to match newlines), and you can use ? to perform non-greedy matching: message = <<-MSG Random