QA Checker 3.0 > Word list Thread poster: Lenart
|
Lenart Luxembourg Local time: 22:06
Hello, I am searching for a way to include this word rule for target: show me an error if this character [ in not at some point of the paragraph followed by this character ] My try was this \[.*[^\]] unfortunately it does not work. any ideas how to achieve that? | | |
Search for missing following character | Aug 29, 2019 |
Try (?=\[)(?!.*\]) | | |
Lenart Luxembourg Local time: 22:06 TOPIC STARTER Anthony thank you!! | Aug 29, 2019 |
I symply tried negative lookahead [(?!.*\]) and it seems to be working. however (?=\[)(?!.*\]) is not working. Could you explain what is the logic behind (?=\[) thank you!! | | |
Be careful when searching for negatives | Aug 29, 2019 |
Consider what \[.*[^\]] means -> basically find something that is not a close square bracket, which will almost always be true. (?=\[) -> positive lookahead to find an open square bracket. (?!.*\])-> negative lookahead to find (the absence of) a close square bracket. | |
|
|
Lenart Luxembourg Local time: 22:06 TOPIC STARTER I wander what is a difference between (?=\[) and simple [ | Aug 29, 2019 |
(?=\[) -> positive lookahead to find an open square bracket. but if I just write [ regex will find an open square bracket. I wander what is a difference between (?=\[) and simple [ | | |
The lookahead (?=\[) basically searches for the presence of a [ The simple [ matches the presence of a [ In this case you could also write [(?!.*\]) which at least in Studio Find/Replace flags a missing close square bracket. I often use such regexes to do a quick QA that I invoke from Find/Replace to find inconsistencies | | |
Lenart Luxembourg Local time: 22:06 TOPIC STARTER hmmmmm so (?=\[) and [ are the same thing, no? | Aug 29, 2019 |
Anthony Rudd wrote: The lookahead (?=\[) basically searches for the presence of a [ The simple [ matches the presence of a [ hmmmmm so (?=\[) and [ are the same thing, no? I don't see any difference between them | | |
The key difference is "search for" and "match". In this particular case, either can be used, but the "negative lookahead" is required to "search for" the missing ] | |
|
|
Lenart Luxembourg Local time: 22:06 TOPIC STARTER QA Checker 3.0 > Word list | Sep 6, 2019 |
Hello, I have one more question with this text: C-529/07, EU:T:2009:361 I want to make a rule> notify error if there is: "C-" followed by 3 to 7 characters of any kind flowed by EU:T my try, that doesn't work, was this: C.*{1,2,3,4,5,6,7,8,9}EU:T: anybody knows where is the problem? | | |
regex expression | Sep 7, 2019 |
C-.{3,7}EU:T | | |
Lenart Luxembourg Local time: 22:06 TOPIC STARTER thank you Anthony!! | Sep 7, 2019 |
this non-gready code works fine too C-.*?EU:T: | | |
But you wanted 3 to 7 characters. | |
|
|
Lenart Luxembourg Local time: 22:06 TOPIC STARTER another qustion | Oct 2, 2019 |
I have this situation: Source:(space)NJ(space) RegEx source: (?>!\w)NJ(?!\w) when I run Regex, nothing is found. Anthony or anybody else, would you be so kind and explain why? to my knowledge \w does not include space, so I would expect this regex to find the source | | |
(?!\w)NJ(?!\w) I would suggest you use a regex test tool, such as RegexHero (licence-free), that provides analysis capability. Such a tool often finds basic errors. | | |
Lenart Luxembourg Local time: 22:06 TOPIC STARTER thank you Anthony! | Oct 3, 2019 |
thank you, yes lookbehind was wrong
[Edited at 2019-10-03 09:31 GMT] | | |