regex-lookarounds

Javascript regex negative lookbehind not working in firefox

对着背影说爱祢 提交于 2019-12-17 07:49:51
问题 I need to modify the following javascript regex because the negative lookbehind in it throws an error in firefox: content = content.replace(/(?![^<]*>)(?:[\"])([^"]*?)(?<!=)(?:[\"])(?!>)/g, '„$1“'); Does anyone have an idea and can help me out? Thanks in advance! 回答1: Lookbehinds are only available in browsers supporting ECMA2018 standard, and that means, only the latest versions of Chrome can handle them. To support the majority of browsers, convert your pattern to only use lookaheads. The (

Javascript regex negative lookbehind not working in firefox

两盒软妹~` 提交于 2019-12-17 07:49:15
问题 I need to modify the following javascript regex because the negative lookbehind in it throws an error in firefox: content = content.replace(/(?![^<]*>)(?:[\"])([^"]*?)(?<!=)(?:[\"])(?!>)/g, '„$1“'); Does anyone have an idea and can help me out? Thanks in advance! 回答1: Lookbehinds are only available in browsers supporting ECMA2018 standard, and that means, only the latest versions of Chrome can handle them. To support the majority of browsers, convert your pattern to only use lookaheads. The (

Combine a positive lookahead and negative lookahead?

做~自己de王妃 提交于 2019-12-14 03:57:22
问题 I am not good with regex, but I have the following, but I assume part of the following means look for 13 - 16 digits and then return a success if it finds 3 - 4 digits after that. The problem is that the 3 - 4 digits are optional and they can also be before the 13 - 16 digit number, so I guess I want to combine a positive lookahead/lookbehind, negative lookahead/lookbehind. This sounds way to complex, is there a simpler way? (\d{13,16})[<"'].*?(?=[>"']\d{3,4}[<"'])[>"'](\d{3,4})[<"'] which

Matching strings not ending with .html

青春壹個敷衍的年華 提交于 2019-12-14 03:24:20
问题 I want to redirect my website users when they hit a REST path without the trailing slash. Example. http://mywebsite.my/it/products/brand/name => http://mywebsite.my/it/products/brand/name/ http://mywebsite.my/it/products => http://mywebsite.my/it/products/ http://mywebsite.my => http://mywebsite.my/ http://mywebsite.my/it/products/brand/name/code.html => ??? Well, I don't want the last one to be rewritten, I don't want the trailing slash when the URL ends with .html . I'm working with URL

regex to find variables surrounded by % in a string

醉酒当歌 提交于 2019-12-13 10:57:59
问题 Need to find "variables" within a string. What denotes a variable is %[/w]+%, the catch is there can be more than one variable within the string: %ABC% %ABC%-%RED% Lorem ipsum %GeT% sit amet, %% consectetur %QW23% elit. In the third example the %% should NOT be found, it will be replaced with a single %. Something like #[\w+-]+# does not work because it cannot determine that in the second line it is %ABC% and %RED%, but rather %-%. I am under the impression that both groups and back

.NET Regex Negative Lookahead - What am I doing wrong (round 2!) [duplicate]

旧巷老猫 提交于 2019-12-13 10:28:18
问题 This question already has an answer here : .NET Regex Negative Lookahead - what am I doing wrong? (1 answer) Closed 3 years ago . I asked this previously and used what I believe to be entirely too simple of a construct, so I'm trying again... Assuming that I have: This is a random bit of information from 0 to 1. This is a non-random bit of information I do NOT want to match This is the end of this bit This is a random bit of information from 0 to 1. This is a non-random bit of information I

Need regex to select the negative pattern selection of html tags

做~自己de王妃 提交于 2019-12-13 10:25:34
问题 I need the regex pattern where it finds the text other than the html tags, (<\s*[^>]*>) And the text is This is simple html text <span class='simple'>simple simple text text</span> text Result should be This is simple html text simple simple text text text Please check the below link https://regex101.com/r/cD8nG4/217 回答1: In the example you gave, it is much easier to find the HTML tags with the regex you already have, and then replace the found strings with empty strings. I have done that

python regex look ahead positive + negative

我的未来我决定 提交于 2019-12-13 01:24:32
问题 This regex will get 456. My question is why it CANNOT be 234 from 1-234-56 ? Does 56 qualify the (?!\d)) pattern since it is NOT a single digit. Where is the beginning point that (?!\d)) will look for? import re pattern = re.compile(r'\d{1,3}(?=(\d{3})+(?!\d))') a = pattern.findall("The number is: 123456") ; print(a) It is in the first stage to add the comma separator like 123,456. a = pattern.findall("The number is: 123456") ; print(a) results = pattern.finditer('123456') for result in

RegEx only matches last item

半腔热情 提交于 2019-12-13 00:45:00
问题 I am trying to write my own syntax highlighter in sublime. I think it uses python-based regular expression. Just want to match all tokens in a row like: description str.bla, str.blub, str.yeah, str.no My regular expression looks like: regex = "(description) (str\\.[\\w\\d]+)(,\\s*(str\\.[\\w\\d]+))*" Now I expect 1 matches in group 1 ("description"), 1 match in group 2 ("str.bla") and 3 matches in my group no 4 ("str.blub", "str.yeah", "str.no") but I have only 1 match in my last group ("str

Negative lookahead with capturing groups

人盡茶涼 提交于 2019-12-12 10:45:31
问题 I'm attempting this challenge: https://regex.alf.nu/4 I want to match all strings that don't contain an ABBA pattern. Match: aesthophysiology amphimictical baruria calomorphic Don't Match anallagmatic bassarisk chorioallantois coccomyces abba Firstly, I have a regex to determine the ABBA pattern. (\w)(\w)\2\1 Next I want to match strings that don't contain that pattern: ^((?!(\w)(\w)\2\1).)*$ However this matches everything. If I simplify this by specifying a literal for the negative