Jump to content

Return a specific string value


Recommended Posts

Hi guys

At the moment I am using StringInStr to find a particular string in a text file. However I need the search to return only the specific value. So for example if I am searching for the word 'findme' the search should only return true if 'findme' is found and return false if 'ufindme' is found

Is this possible? I was thinking of using StringRegExp for this purpose but i am not sure....

Thanks

Link to comment
Share on other sites

Do you want the code to return true when "findme" is the only word in the text file, or the only word on a line? Please upload an example file if possible.

Link to comment
Share on other sites

Hi guys

At the moment I am using StringInStr to find a particular string in a text file. However I need the search to return only the specific value. So for example if I am searching for the word 'findme' the search should only return true if 'findme' is found and return false if 'ufindme' is found

Is this possible? I was thinking of using StringRegExp for this purpose but i am not sure....

Thanks

You haven't covered all the Boolean cases: What if neither is found... or both?

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Do you want the code to return true when "findme" is the only word in the text file, or the only word on a line? Please upload an example file if possible.

At the moment my script says that a string is found if it finds 'findme' on a particular line. However I need my script to flag an error if it reads the following on line 2:

line1

line2findmeline2

line2

Thanks

Link to comment
Share on other sites

I do repeat the question: in what type of file do you try to find "findme"?

Maybe just including spaces in the search string may do the trick ...

" findme "

Nice try but this does not work as there are no spaces on the line which 'findme' excist's. The file I am searching is a .txt file opened in Notepad.

Link to comment
Share on other sites

I think you've now answered a couple of the questions in prior responses.

Those regarding what specifically it is that you wish to do.

To me, it's beginning to look like something as simple as:

If FileReadLine($file) = "findme" Then ...

is what you're after.

Posting your code, or a portion of it, would likely clarify things for everyone here.

Link to comment
Share on other sites

Please give several more examples of desired and undesired parameters:

For example, you want to successfully trigger off of "boo":

The baby cried boo hoo hoo.

I need to make a boolean expression

The ghost shouted BOO

But you do not want:

That subject is taboo.

The engine got a sudden boost.

12345boo890

etc... We are trying to find a pattern and we are just guessing because you are not giving us enough to work with.

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Hi guys

Thanks for everybodies suggestions.

I think I have found a work around for this one. As it happens (by a supreme stroke of luck) each line of the text file I am reading has one space after it. Consequently when I assign the string to my variable I simply add the space, i.e

$find='findme '

This then rules out me finding 'findme123' as opposed to just 'findme' when 'findme123' is in the text file... :P

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...