regex-negation

Multiple Conditions in Validation Regex

感情迁移 提交于 2021-02-15 06:54:45
问题 I am more or less a regex novice. I tried to get the following conditions into a regex: No White Space at the beginning and at the end of a string Allow all digits Allow spaces, points, brackets, plus and minus Resulted in the following regex: ^\S[\d\/. ()\-+]*\S$ But now i try to apply two more conditions: Allow only one or two + Allow only one ( and one ) My problem is how to merge those two conditions into the existing regex string above cuz excluding + [+]{1,2} and () [(]{1} [)]{1} doesn

Multiple Conditions in Validation Regex

蓝咒 提交于 2021-02-15 06:54:12
问题 I am more or less a regex novice. I tried to get the following conditions into a regex: No White Space at the beginning and at the end of a string Allow all digits Allow spaces, points, brackets, plus and minus Resulted in the following regex: ^\S[\d\/. ()\-+]*\S$ But now i try to apply two more conditions: Allow only one or two + Allow only one ( and one ) My problem is how to merge those two conditions into the existing regex string above cuz excluding + [+]{1,2} and () [(]{1} [)]{1} doesn

Regex to include one thing but exclude another

痞子三分冷 提交于 2021-02-07 14:55:09
问题 I've been having a lot of trouble finding how to write a regex to include certain URLs starting with a specified phrase while excluding another. We want to include pages that start with: /womens /mens /kids-clothing/boys /kids-clothing/girls /homeware But we want to exclude anything that has /sXXXXXXX in the URL - where the X's are numbers. I've written this so far to match the below URLs but it's behaving very oddly. Should I be using lookarounds or something? \/(womens|mens|kids\-clothing\

Regex to include one thing but exclude another

帅比萌擦擦* 提交于 2021-02-07 14:54:19
问题 I've been having a lot of trouble finding how to write a regex to include certain URLs starting with a specified phrase while excluding another. We want to include pages that start with: /womens /mens /kids-clothing/boys /kids-clothing/girls /homeware But we want to exclude anything that has /sXXXXXXX in the URL - where the X's are numbers. I've written this so far to match the below URLs but it's behaving very oddly. Should I be using lookarounds or something? \/(womens|mens|kids\-clothing\

RegEX match everything outside square brackets

江枫思渺然 提交于 2021-02-07 07:59:41
问题 I'm playing around with the WP editor and I'd like to create a RegEX pattern that matches everything outside the square brackets like this: [foo]Some selected text here[/foo]More selected text here And replace with [foo][text_box text="Some selected text here"][/textbox][/foo] [text_box text="More selected text here"][/textbox] I managed to match the square brackets content using (\[(.*?)\]) How can I match everything else? Thank you very much for your help! 回答1: Can your text contain [ ? If

RegEX match everything outside square brackets

匆匆过客 提交于 2021-02-07 07:59:17
问题 I'm playing around with the WP editor and I'd like to create a RegEX pattern that matches everything outside the square brackets like this: [foo]Some selected text here[/foo]More selected text here And replace with [foo][text_box text="Some selected text here"][/textbox][/foo] [text_box text="More selected text here"][/textbox] I managed to match the square brackets content using (\[(.*?)\]) How can I match everything else? Thank you very much for your help! 回答1: Can your text contain [ ? If

RegEX match everything outside square brackets

♀尐吖头ヾ 提交于 2021-02-07 07:57:34
问题 I'm playing around with the WP editor and I'd like to create a RegEX pattern that matches everything outside the square brackets like this: [foo]Some selected text here[/foo]More selected text here And replace with [foo][text_box text="Some selected text here"][/textbox][/foo] [text_box text="More selected text here"][/textbox] I managed to match the square brackets content using (\[(.*?)\]) How can I match everything else? Thank you very much for your help! 回答1: Can your text contain [ ? If

RegEX match everything outside square brackets

若如初见. 提交于 2021-02-07 07:57:30
问题 I'm playing around with the WP editor and I'd like to create a RegEX pattern that matches everything outside the square brackets like this: [foo]Some selected text here[/foo]More selected text here And replace with [foo][text_box text="Some selected text here"][/textbox][/foo] [text_box text="More selected text here"][/textbox] I managed to match the square brackets content using (\[(.*?)\]) How can I match everything else? Thank you very much for your help! 回答1: Can your text contain [ ? If

Regex to parse out a part of URL

假装没事ソ 提交于 2021-02-05 08:01:24
问题 I am having the following data, data http://hsotname.com/2016/08/a-b-n-r-y-u https://www.hostname.com/best-food-for-humans http://www.hostname.com/wp-content/uploads/2014/07/a-w-w-2.jpg http://www.hostname.com/a/geniusbar/ http://www.hsotname.com/m/ http://www.hsotname.com/ I want to avoid the first http:// or https:// and check for the last '/' and parse out the remaining parts of the URL. But the challenge here is, we have '/' on the end of few URLs as well. The output which I want is,

How to make exceptions for certain words in regex

大憨熊 提交于 2021-02-05 08:00:10
问题 I'm very new in programming and regex so apologise if this's been asked before (I didn't find one, though). I want to use Python to summarise word frequencies in a literal text. Let's assume the text is formatted like Chapter 1 blah blah blah Chapter 2 blah blah blah .... Now I read the text as a string, and I want to use re.findall to get every word in this text, so my code is wordlist = re.findall(r'\b\w+\b', text) But the problem is that it matches all these Chapter s in each chapter title