regex-group

Raku regex: How to use capturing group inside lookaheads

落爺英雄遲暮 提交于 2021-02-20 06:32:30
问题 How can I use capturing groups inside lookahead assertion? This code: say "ab" ~~ m/(a) <?before (b) > /; returns: 「a」 0 => 「a」 But I was expecting to also capture 'b'. Is there a way to do so? I don't want to leave 'b' outside of the lookahead because I don't want 'b' to be part of the match. Is there a way to capture 'b' but still leave it outside of the match? NOTE: I tried to use Raku's capture markers, as in: say "ab" ~~ m/<((a))> (b) /; 「a」 0 => 「a」 1 => 「b」 But this does not seem to

Raku regex: How to use capturing group inside lookaheads

随声附和 提交于 2021-02-20 06:32:14
问题 How can I use capturing groups inside lookahead assertion? This code: say "ab" ~~ m/(a) <?before (b) > /; returns: 「a」 0 => 「a」 But I was expecting to also capture 'b'. Is there a way to do so? I don't want to leave 'b' outside of the lookahead because I don't want 'b' to be part of the match. Is there a way to capture 'b' but still leave it outside of the match? NOTE: I tried to use Raku's capture markers, as in: say "ab" ~~ m/<((a))> (b) /; 「a」 0 => 「a」 1 => 「b」 But this does not seem to

Raku regex: How to use capturing group inside lookaheads

一世执手 提交于 2021-02-20 06:29:33
问题 How can I use capturing groups inside lookahead assertion? This code: say "ab" ~~ m/(a) <?before (b) > /; returns: 「a」 0 => 「a」 But I was expecting to also capture 'b'. Is there a way to do so? I don't want to leave 'b' outside of the lookahead because I don't want 'b' to be part of the match. Is there a way to capture 'b' but still leave it outside of the match? NOTE: I tried to use Raku's capture markers, as in: say "ab" ~~ m/<((a))> (b) /; 「a」 0 => 「a」 1 => 「b」 But this does not seem to

Guide on how to use regex in Nginx location block section?

风流意气都作罢 提交于 2021-02-17 08:28:56
问题 Nginx regex location syntaxe Regex expressions can be used with Nginx location block section, this is implemented with the PCRE engine. What does exactly this feature support as it is not fully documented? 回答1: Nginx location: Nginx location block section have a search order, a modifier, an implicit match type and an implicit switch to whether stop the search on match or not. the following array describe it for regex. # -------------------------------------------------------------------------

How to add information found with regular expressions in a CSV file

眉间皱痕 提交于 2021-02-11 06:32:45
问题 I am trying to "append" new information to a CSV file. The problem is that that information is not in a dataframe structure, but is information extracted from a text using regular expressions. The sample text would be the next one: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id diam posuere, eleifend diam at, condimentum justo. Pellentesque mollis a diam id consequat. TITLE-SDFSD-DFDS-SFDS-01-01: This is the title 1 that is split into two lines with a blank line in the

How to add information found with regular expressions in a CSV file

被刻印的时光 ゝ 提交于 2021-02-11 06:31:28
问题 I am trying to "append" new information to a CSV file. The problem is that that information is not in a dataframe structure, but is information extracted from a text using regular expressions. The sample text would be the next one: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id diam posuere, eleifend diam at, condimentum justo. Pellentesque mollis a diam id consequat. TITLE-SDFSD-DFDS-SFDS-01-01: This is the title 1 that is split into two lines with a blank line in the

How to add information found with regular expressions in a CSV file

随声附和 提交于 2021-02-11 06:31:27
问题 I am trying to "append" new information to a CSV file. The problem is that that information is not in a dataframe structure, but is information extracted from a text using regular expressions. The sample text would be the next one: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id diam posuere, eleifend diam at, condimentum justo. Pellentesque mollis a diam id consequat. TITLE-SDFSD-DFDS-SFDS-01-01: This is the title 1 that is split into two lines with a blank line in the

JavaScript replaceAll case-insensitive search using variable rather than a string

这一生的挚爱 提交于 2021-02-08 08:39:40
问题 I want to do a JavaScript replaceAll() using a variable (rather than a string) in a case-insensitive search, but also retaining the case of the matched text (in the return). For example, console.log('doc.p:', doc.p.toString().substring(0, 26)) var query = this.manager.store.get('q').value.toString(); console.log('query:', query, '| type:', typeof(query)) console.log(doc.p.toString().replaceAll(/(dna)/gi, '***$1***')) console.log(doc.p.toString().replaceAll(/(query)/gi, '***$1***')) is giving

count occurrences of a string pattern in a file and count

巧了我就是萌 提交于 2021-01-29 09:48:34
问题 Team, I am trying to count two patterns in a file and list them as pattern1: 2 pattern2: 3 #!/usr/bin/python import os import re d = dict() with open('/home/user/waste/nodes-prod.log', 'r') as file: for line in file: line = line.strip() for word in line.split(): node1 = re.match(r"team1.*", word) type(node1) node2 = re.match(r"team2.*", word) type(node2) if node1 in d: d[node1] = d[node1] + 1 else: d[node2] = d[node2] + 1 for key in list(d.keys()): print(key, ":", d[key]) my /home/user/waste

Regex expression for file name with 2 underscores and 3 segments

和自甴很熟 提交于 2021-01-29 07:30:57
问题 I need a regex expression that will select files with particular file name format from the file list of properties files. I need to select files with file names with following file format: <app_name>_<app_version>_<environment>.properties here <app_name> can be any alphanumeric with special character <A-Z/a-z/0-9/special char> like abc123 or app1-1 here <app_version> can be any alphanumeric with special character <A-Z/a-z/0-9/special char/float value> like abc or even float/integer/string 1.0