How to edit a Text file in MAX?

Djondub's icon

Hi there

I would like to find a way to edit some text files automatically.
For example if I have this text in my text files, I want to extract the number in between "toilets" and "times":

Text file 1:
"Robert has been to the toilets 200 times today"
result: "200"

Text file 2:
"Robert has been to the toilets 22 times today"
result: "22"

Anyone knows how to do that???
Many thanks

Jon
--

Gregory Taylor's icon

Since what you want to do isn't really well described, I'd suggest that you take a look at the zl object [which would let you group, split, output and concatenate lists] or the route object [which will strip off something you watch for and pass the rest along] or the regexp objects [which will do all kinds of UNIX-style searche/replace operations].

Try looking at those objects as a start....

Matthias S.'s icon

maybe this could help you...

Max Patch
Copy patch and select New From Clipboard in Max.

Sam Thursfield's icon

Max is probably one of the worst tools for this job, after perhaps MS Paint. Have you thought about using some Javascript?

Djondub's icon

Thanks Gregory.
Sorry for not being too clear.....here is what I'd like to achieve:

I am using a text file generated from an URL page source (myspace page). I am trying to extract a data from this page source which is the number of profile views.
What I want to do is to be able to extract the number that is next to the "profile views" part in the text.

For example, I want to remove everything but the number "26563" below, how do I do that?? :

bgcolor="#ffffff" class="text">
                                yes it is yes it is yes it is oh yes it is

                        Leeds/LA/Grenoble/Northampton, London and South East

                        United Kingdom

                        Profile Views: 
                        26563

                        Last Login: 
                        01/02/2010

Matthias S.'s icon

this would be my attempt to solve it.
but I still have the feeling that it isn't the perfect way of doing it.

Max Patch
Copy patch and select New From Clipboard in Max.

Luke Hall's icon

If you're grabbing the source with [jit.uldl] then try something like this.

Max Patch
Copy patch and select New From Clipboard in Max.

lh

Djondub's icon

many thanks I'm nearly there....the code is too long so It doesn't seem to work...do you wanna have a try?

    ENCHUFADA on MySpace Music - Free Streaming MP3s, Pictures & Music Videos

Luke Hall's icon

Haha you only needed to post the link! The problem was the spaces between the "Profile Views:" and the actual number is a non-breaking space which in html is

Djondub's icon

thanks mate, yeah it works perfectly now!
Good work!!
Best wishes to all
Jon

Roman Thilenius's icon

the [text] object, some zl and some sprintf ist really all you need.