regex

How can I get “grep -zoP” to display every match separately?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 14:35:05
问题 I have a file on this form: X/this is the first match/blabla X-this is the second match- and here we have some fluff. And I want to extract everything that appears after "X" and between the same markers. So if I have "X+match+", I want to get "match", because it appears after "X" and between the marker "+". So for the given sample file I would like to have this output: this is the first match and then this is the second match I managed to get all the content between X followed by a marker by

Regex Find Spaces between single qoutes and replace with underscore

老子叫甜甜 提交于 2021-02-07 14:28:29
问题 I have a database table that I have exported. I need to replace the image file name with a space and would like to use notepad++ and regex to do so. I have: 'data/green tea powder.jpg' 'data/prod_img/lumina herbal shampoo.JPG' 'data/ALL GREEN HERBS.jpeg' 'data/prod_img/PSORIASIS KIT (640x530) (2).jpg' and need to make them look like this: 'data/green_tea_powder.jpg' 'data/prod_img/lumina_herbal_shampoo.JPG' 'data/ALL_GREEN_HERBS.jpeg' 'data/prod_img/PSORIASIS_KIT_(640x530)_(2).jpg' I just

Regex decimal values between 0 and 1 up to 4 decimal places

我怕爱的太早我们不能终老 提交于 2021-02-07 14:20:51
问题 I am writing a C# web application and verify data in a textbox using this regular expression that only accepts positive decimal values between 0 and 1: ^(0(\.\d+)?|1(\.0+)?)$ I would to adapt like the regex to restrict entries to 4 decimal places of precision. Allowed 0 0.1 0.12 0.123 0.1234 1 Not allowed -0.1 -1 1.1 2 I have found the following regex that only allows up to 4 decimal places, but I am unsure on how to combine the two. ^(?!0\d|$)\d*(\.\d{1,4})?$ Any help is greatly appreciated,

Is there a way to convert tables of text into a PowerShell Object

☆樱花仙子☆ 提交于 2021-02-07 14:15:44
问题 There are many tools that output their data in in a table format. One such example is diskpart. Shaving off some extraneous output, you would get something like this. Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 136 GB 0 B Disk 1 Offline 136 GB 136 GB Disk 2 Reserved 1027 MB 0 B * Disk 3 Reserved 500 GB 0 B * Disk 4 Reserved 500 GB 0 B * Disk 5 Reserved 10 GB 0 B * Disk 6 Reserved 13 GB 0 B * Disk 7 Reserved 4102 MB 0 B * Disk 8 Reserved 7169

Google BigQuery possible to do Case-Insensitive REGEXP_Match?

天大地大妈咪最大 提交于 2021-02-07 13:46:00
问题 In Google BigQuery I wanted to check for 'confirm' or 'Confirm': REGEXP_CONTAINS(h.page.PagePath, r'Confirm') or REGEXP_CONTAINS(h.page.PagePath, r'confirm')) I am a Perl person and in Perl we do $foo =~ /confirm/i # case-insensitive Does Google BigQuery have any flags to modify REGEXP_MATCH? I did not see any examples in their online docs. 回答1: REGEXP_CONTAINS uses RE2 library, so you may use inline modifiers like this: REGEXP_CONTAINS(h.page.PagePath, r'(?i)confirm') ^^^^ See RE2 docs: (

Google BigQuery possible to do Case-Insensitive REGEXP_Match?

本秂侑毒 提交于 2021-02-07 13:45:39
问题 In Google BigQuery I wanted to check for 'confirm' or 'Confirm': REGEXP_CONTAINS(h.page.PagePath, r'Confirm') or REGEXP_CONTAINS(h.page.PagePath, r'confirm')) I am a Perl person and in Perl we do $foo =~ /confirm/i # case-insensitive Does Google BigQuery have any flags to modify REGEXP_MATCH? I did not see any examples in their online docs. 回答1: REGEXP_CONTAINS uses RE2 library, so you may use inline modifiers like this: REGEXP_CONTAINS(h.page.PagePath, r'(?i)confirm') ^^^^ See RE2 docs: (

Regex to parse package name and version number from nuget package filenames

浪尽此生 提交于 2021-02-07 13:41:02
问题 I have a directory of nuget packages that I've downloaded from nuget.org. I'm trying to create a regex that will parse out the package name and version number from the filename. It doesn't seem difficult at first glance; the filenames have a clear pattern: {PackageName}.{VersionNumber}.nupkg Edge cases make it challenging though. Package names can have dashes, underscores, and numbers Package names can have effectively unlimited parts separated by dots Version numbers consist of 3-4 groups of

Regex to parse package name and version number from nuget package filenames

陌路散爱 提交于 2021-02-07 13:39:45
问题 I have a directory of nuget packages that I've downloaded from nuget.org. I'm trying to create a regex that will parse out the package name and version number from the filename. It doesn't seem difficult at first glance; the filenames have a clear pattern: {PackageName}.{VersionNumber}.nupkg Edge cases make it challenging though. Package names can have dashes, underscores, and numbers Package names can have effectively unlimited parts separated by dots Version numbers consist of 3-4 groups of

Python3 regex on bytes variable [duplicate]

被刻印的时光 ゝ 提交于 2021-02-07 13:37:52
问题 This question already has answers here : TypeError: sequence item 1: expected a bytes-like object, str found (3 answers) Closed 3 years ago . I'm trying to perform a regex substitution on a bytes variable but I receive the error sequence item 0: expected a bytes-like object, str found Here is a small code example to reproduce the problem with python3: import re try: test = b'\x1babc\x07123' test = re.sub(b"\x1b.*\x07", '', test) print(test) except Exception as e: print(e) 回答1: When acting on

Regex for matching multilingual numbers not detecting Chinese numbers

╄→гoц情女王★ 提交于 2021-02-07 13:34:37
问题 I have a method which detects whether a String is a number: public static boolean isNumber(String num) { return num.matches("(\\p{N})+"); } The above method is successfully matching English, Hindi, Arabic numbers but fails to match Chinese numbers: 三十萬零二百五十 etc. Is it possible to create a regex which can match a number from any language(or major languages)? edit: the number won't be a decimal, it will be used to validate a phone number. 回答1: as some have already pointed out in the comments,