Detecting language please wait for.......
Disclaimer: I'm a beginner where Regex is concerned, so apologies if this is a silly question!
I'd like to set up a Regex QA check to flag up target segments where I've forgotten to use the preposition "on" after the verb "click".
The best I've come up with is to enter Click [^o] in the RegEx target box, with "Report if target matches (target check only)" as the condition. But obviously this is case sensitive and doesn't cover "clicks", "clicking", "clicked".
Does anyone have any suggestions for a more "comprehensive" rule that would save me entering all the different variants (click, Click, CLICK, clicking, Clicking, CLICKING and so on and so on...!)?
Thanks for this! I don't know if it's the most concise version(!), but this works:(c|C)(lic|LIC)(k|K|ks|KS|ked|KED|king|KING) [^o]
Maybe use this to find the click variants in any case:
You can say both. Naturally I would say/write "Click something" too, hence the interest in flagging up segments for this particular client who insists on the preposition! But as I said to Paul, I was partly…
Hayley said:I'd like to set up a Regex QA check to flag up target segments where I've forgotten to use the preposition "on" after the verb "click".
If this isn't translated then check to see if the source finds this:
Then check to see if the target finds the same thing.
Rather than using the more complex [^\s], which can be written as \S (i.e. not a whitespace), it would be less confusing to write \w*
click\w*\sonThe QA Checker - Regular Expressions provides an "Ignore Case" checkbox.
Doesn't your version find the opposite, i.e. "click/s/ed/ing on"? I wanted to find occurrences of "click" that are NOT followed by "on".Thanks for the tip about the Ignore Case checkbox though (although I'm glad to have learned the RegEx solution too).
Here a solution which finds "click", "clicks", "clicked" or "clicking" when they are not followed by "on":click(s|ed|ing)?\b(?! on)It uses a word boundary "\b" and a negative lookahead "(?! on).
You are of course correct, I commented on the regex rather than looking at the original question.
Thanks for this version Raphaël Toussaint!
Rather than specifying explicit suffixes in Raphaël’s solution (such as “s|ed|ing”), using the generic \w* metacharacter with quantifier click\w*(?!\son) can simplify the regex when many variants need to be coded, but results in an interesting phenomenon in conjunction with negative lookahead; backtracking can cause “false matches”, such as “clicking on”. This problem can be avoided with an atomic group, which is probably the least understood regex construct because almost all regex textbooks provide a very poor description with abstruse examples; an atomic group (?>…) prevents backtracking. The correct regex is click(>\w*)(?!\son)
To prevent false positives, such as “click one button”, it may be better to code (?!\son\b)
Anthony Rudd Thanks for the atomic group explanation - very useful for something I am currently working on.
I am pleased to be able to help. As I mentioned, the useful of atomic groups is not generally appreciated; indeed, an acknowledged regex guru did not use a needed atomic group in one of his examples (at least in an early edition of his book).