How do I identify a sentence with regex?

Get help using Construct 2

Post » Fri Oct 13, 2017 2:25 pm

Hi Guys, I need help. Is there a way to identify a sentence that has only one word using regex?

Thanks in Advance.
B
24
S
7
Posts: 337
Reputation: 2,224

Post » Fri Oct 13, 2017 2:50 pm

This tutorial is very detailed: https://www.scirra.com/tutorials/1337/e ... onstruct-2

And this site may help you test your regex: https://regexr.com/

If you need something more specific, give us more details about it or share a capx that I'll be glad to take a look at it.

Hope this helps. Cheers!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
21
S
6
G
3
Posts: 664
Reputation: 3,855

Post » Fri Oct 13, 2017 3:27 pm

Ok, I should warn that I have zero experience with regex and this is my first ever regex pattern.
I was stunned when I got it right from the first attempt!
Code: Select all
RegexMatchAt(text, "[.|!|?]\s+(\w+[.|!|?])", "i", 1)


There is at least one problem with it - if the one-word sentence is in the beginning of the text, it won't be caught.
Also, it only searches for well-formatted sentences ending either with full stop, exclamation mark or question mark.
There may be other issues. But hey, I'm still proud! :)
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
72
Posts: 1,085
Reputation: 39,233

Post » Mon Oct 16, 2017 5:38 pm

@brunopalermo @dop2000, thanks alot guys. I will try them. :D
B
24
S
7
Posts: 337
Reputation: 2,224


Return to How do I....?

Who is online

Users browsing this forum: dop2000, hao102a2 and 27 guests