-3

I would appreciate suggestions on how to write a code for this:

if root (word xxx) AND (root word yyy) are BOTH in the same sentence then ...

If I am not wrong the codes for the roots are:

(xxx[a-zA-Z]) AND (yyy[a-zA-Z])

but I don’t know how to say that they are both in the sentence.

(I need this as regex code that will be imported in SDL studio verification tool)

Any help would be highly appreciated

Leny
  • 3
  • 3
  • use look ahead assertion – Pranav C Balan Jun 13 '17 at 08:11
  • Welcome to stackoverflow.com. Please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named "[What topics can I ask about here?](http://stackoverflow.com/help/on-topic)" and "[What types of questions should I avoid asking?](http://stackoverflow.com/help/dont-ask)". Also please [take the tour](http://stackoverflow.com/tour) and read about [how to ask good questions](http://stackoverflow.com/help/how-to-ask). Lastly please learn how to create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). – ArturFH Jun 13 '17 at 08:47
  • [Sample Data!](https://stackoverflow.com/help/mcve) Do you handle punctuation? Do you handle number? – Drag and Drop Jun 13 '17 at 08:53
  • Possible duplicate of [Regular Expressions: Is there an AND operator?](https://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator) – Drag and Drop Jun 13 '17 at 08:58

1 Answers1

0

As this question says you need to use a non-consuming regular expression.

Typical notation is (?=expression).

This means "match expression and then carry on from the match point".

You can chain them together like this (?=first thing)(?=more stuff)(?=even more) to achieve your "and".

If you're struggling with regex generally you might wish to have a look at this regex cheat sheet and this regex tester.

Gareth
  • 913
  • 6
  • 14
  • thank you for your answer Greth, however this doesnt work for me. I tried to this code (?=xxx)(?=yyy) and have no results. (I need this as regex code that will be imported in SDL studio verification tool (translation tool) Is there a different way to write this? – Leny Jun 13 '17 at 10:56
  • I accept your answer with pleasure, but I still don't konw why „code (?=xxx)(?=yyy)“ does not work in my regex tool – Leny Jun 13 '17 at 12:02