Hi,
I'm using regex in our project. How can I check 2 strings in a sentence?
For example like below, if a sentence has "is" and "sentence" words, I want to choose it.
"this is a test sentence"
How can I do this?
regards.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 26, 2013, 12:46 AM EDT
Regards,
Iftikar
yokzuRank #5,421 · 300 reputationPosted Jul 25, 2013, 11:17 PM EDT
^(this).\btest\bSunny SharmaRank #223 · 11.1K reputationPosted Jul 25, 2013, 11:18 PM EDT
use this regex:
(\bis\b)(?:[^.]|\.\s)*(\bsentence\b)
Happy Coding :)
Cheers!
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 11:28 PM EDT
Try like this
Regards,
Iftikar
yokzuRank #5,421 · 300 reputationPosted Jul 25, 2013, 11:37 PM EDT
It doesnt work:/
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 11:38 PM EDT
Regards,
Iftikar
Sunny SharmaRank #223 · 11.1K reputationPosted Jul 25, 2013, 11:42 PM EDT
read it like this:
(\bWORD1\b)(?:[^.]|\.\s)*(\bWORD2\b)
It will work, tested solution.
yokzuRank #5,421 · 300 reputationPosted Jul 25, 2013, 11:51 PM EDT
I tryed your code too but it didnt work.
Sorry maybe I write the wrong example.
"ABCD-5-DCEG: Process 111, Nbr 1.1.1.1 on from FULL to DOWN, Neighbor Down:"
The example is like above.
I want to choose if starts with "ABCD-5-DCEG:" and contain "DOWN" words.
VulpesRank #55 · 29.2K reputationPosted Jul 26, 2013, 12:28 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 26, 2013, 12:43 AM EDT
now you have asking different expression.
Regards,
Iftikar