regexp - search for a phrase i.e. more than one word
Dear Forum
I would like to use regexp to search for a phrase in a txt file e.g. "gold 1965" so that it only returns if both words are present. As this is user facing I need this to happen in one action, ideally.
I've done some searching(forum/discord)/read regexp tutorials and tried "gold + 1965" but without success.
Any help gratefully received.
Thanks
Russ
What should "return" be, a bang, whole sentence containing the phrase , or only text line ?
Please excuse me being not specific.
I am searching through lines in a txt file.
For me the return is the line so that I can then deliver that part of the txt file.
I have successfully set up a version searching for a single word (thanks to Ben Bracken) and delivering all the lines with that word in.
I’d like to increase the sensitivity so that a user could search for a phrase of one, two or three words, ideally not case specific.
Any help appreciated.
As it is a text line and not a sentence, you don't need more then to dump text from text object,
match the phrase and output the line.
I woud convert line into ascii, iter to match object set to listen to entered phrase, also as ascii string.
Insert atoi and iter at text output and feed that into match object.
You can use textedit to let users enter the phrase and again insert atoi , prepend set to make match object listen to set phrase.
I have no max at hand to post the patch, but later tonight if you don't manage to make it work
I’d appreciate the patch as I have done little ASCII patching. Thanks.
here is the patch compatible with max 8.6.5
it is about converting all text to lower case (you asked for that )
there are many ways to do that, I picked string.tolower
because I don't use max 9.
if you prefer js here is simple code:
function anything() {var str = arrayfromargs(messagename, arguments).join(" ");
outlet(0, str.toLowerCase());}
P.S. I used dialog to enter phrase to match, but you can replace it with whatever else you want.
Thank you so much for this. I’ll check it out tomorrow UK time.
for more simple use cases, note the [match] object.
yes, match can work with symbols, and without need to convert upper to lower cases
it could be pretty simpler.
one could remove atoi as well .

Thanks both for your help.
I had not heard of [match]
PS [match] works a treat!
Thanks so much both