regex

Regexp exact word match

霸气de小男生 提交于 2021-01-28 04:32:09
问题 I need to match words from lines. For example: The blue bird is dancing. Yellow card is drawn The day is perfect rainy blue bird is eating The four lines are in a text file l2 . I want to match the blue bird, yellow card, day and every time a line is printed that matched word is printed before the line. y=regexp(l2,('^(?=.*blue bird)|(?=.*day)|(?=.*Yellow card)$')); Is this how it works? I can't get the result. sprintf('[%s]',y,l2); 回答1: MATLAB's regex engine doesn't use \b as word boundary

REGEX for search and exclude combined

南楼画角 提交于 2021-01-28 04:20:55
问题 Overview: I am trying to combine two REGEX queries into one: \d+\.\d+\.\d+\.\d+ ^(?!(10\.|169\.)).*$ I wrote this as a two part query. The first part would isolate IPs in a block of text and after I copy and paste this I select everything and that does not being with a 10 or 169. Questions: It seems like I am over complicating this: Can anybody see a better way to do this? Is there a way to combine these two queries? 回答1: A quick-and-gimme-regex style answer Basic one (whole string looks like

Change XML tags within PowerShell and keep content.

徘徊边缘 提交于 2021-01-28 04:16:57
问题 I have exported data from an EventLog using PowerShell and have created a sample Schema to import the data into SQL however there is an issue of the way the data is exported from PowerShell using ConvertToXML. The exports of the XML looks like this; <Property Name="Version">0</Property> <Property Name="Qualifiers" /> <Property Name="Level">0</Property> <Property Name="Task">14339</Property> <Property Name="Opcode">0</Property> <Property Name="Keywords">-9218868437227405312</Property>

Non-delivery reports and VBA script in Outlook 2010

独自空忆成欢 提交于 2021-01-28 04:15:19
问题 I have a Outlook 2010 VBA script that should scan the body of selected non-delivery reports in my inbox and generates a text report if they match certain regular expressions in the body. Recently the script stopped working and it seems like I can no longer access the .body of the selected objects (debug.print outputs a lot of question marks to the immediate window). The script still works fine for regular (not NDR) emails in my inbox. I also noticed that the non-delivery reports all of a

Regex in lxml for python

旧时模样 提交于 2021-01-28 04:10:08
问题 I having trouble implementing regex within xpath command. My goal here is to download the html contents of the main page, as well as the contents of all hyperlinks on the main page. However, the program throws exceptions because some of the href links do not connect to anything (ex. '//:javascript', or '#'). How would I use regex in xpath? Is there an easier way to except non-absolute hrefs? from lxml import html import requests main_pg = requests.get("http://gazetaolekma.ru/") with open(

Regex for a permutation of exactly 7 digits and 2 hyphens, without 2 consecutive hyphens

微笑、不失礼 提交于 2021-01-28 04:09:34
问题 I a looking for a Regex to match a string which should: start with a digit 'in-between' have a permutation of exactly 7 digits and 2 hyphens, without 2 consecutive hyphens end with a sequence of digit, hyphen, digit Match: 01-234-5678-9 01234-56-78-9 0123-4-5678-9 012-345-678-9 01-234567-8-9 01-234-5678-9 0-12345-678-9 0-123-45678-9 0-123-45678-9 01-23456-78-9 0-123456-78-9 0-1234567-8-9 No Match: 01-234-56789-0 01-234-567-8 01--2345678-9 01-2345678--9 0-1-23456789 -01-2345678-9 For now, I

Replace one character but not two in a string

流过昼夜 提交于 2021-01-28 04:07:47
问题 I want to replace single occurrences of a character but not two in a string using C#. For example, I want to replace & by an empty string but not when the ocurrence is && . Another example, a&b&&c would become ab&&c after the replacement. If I use a regex like &[^&] , it will also match the character after the & and I don't want to replace it. Another solution I found is to iterate over the string characters. Do you know a cleaner solution to do that? 回答1: You can match both & and && (or any

Python using diferent options multiple times with argparse

巧了我就是萌 提交于 2021-01-28 04:00:32
问题 I am working on a custom Nagios script in which I would like to implement parsing of command line arguments in the same way that is used on existing Nagios Plugin check_disk . In that plugin you have an option parameter -C to Clear current config and start over with new parameters. Extracted from check_disk help: check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar ----(3)----- ---------(1)---------- --------(2)-------- Checks warning/critical thresholds: for volume /foo

Python using diferent options multiple times with argparse

流过昼夜 提交于 2021-01-28 03:50:59
问题 I am working on a custom Nagios script in which I would like to implement parsing of command line arguments in the same way that is used on existing Nagios Plugin check_disk . In that plugin you have an option parameter -C to Clear current config and start over with new parameters. Extracted from check_disk help: check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar ----(3)----- ---------(1)---------- --------(2)-------- Checks warning/critical thresholds: for volume /foo

RegExp - find all occurences, but not inside quotes

冷暖自知 提交于 2021-01-28 03:25:07
问题 I have this text (it's a string value, not a language expression): hello = world + 'foo bar' + gizmo.hoozit + "escaped \"quotes\""; And I would like to find all words ( [a-zA-Z]+ ) which are not enclosed in double or single quotes. The quotes can be escaped ( \" or \' ). The result should be: hello, world, gizmo, hoozit Can I do this using regular expressions in JavaScript? 回答1: you can use this pattern, what you need is in the second capturing group: EDIT: a little bit shorter with a