Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: Search a word in a txt file
Topic Summary:
Created On: 08/14/2009 03:40 PM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
 08/14/2009 03:40 PM
User is offline View Users Profile Print this message

Author Icon
Barbar
Expert (100-199)

Posts: 110
Joined: 07/02/2007

Hi

I'm trying to find a specific word in a text file (.txt), and to copy the text after it (I don't know what is the text,it changes)

this document contains this word 5 times. and I want to copy the text after each word and to separate it (word 1, word 2 etc.)

How can I do it ?

I hope this is understandable

thank you

Barbar



 Category Survey
 08/15/2009 09:07 AM
User is offline View Users Profile Print this message

Author Icon
Barbar
Expert (100-199)

Posts: 110
Joined: 07/02/2007

at the moment i'm using:%Instr(http,wordtofind)%

to get the first word

how can i get to the second one?

 



 Category Survey
 08/18/2009 04:01 PM
User is offline View Users Profile Print this message

Author Icon
Nick
AUTOMATE EMPLOYEE

Posts: 22
Joined: 05/31/2005

Barbar,

Can you provide us with a sample text file that we can look at it? We want to make sure we understand what data your trying to capture and what to do with the data.

 Category Survey
 08/18/2009 10:14 PM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Barbar,
once you found the first word using %Instr(http,wordtofind)% into p1
you can find the following one using %Instr(p1+len(wordtofind),http,wordtofind)%
and so on
hereunder the help for InStr
InStr Function Syntax: InStr([Index, ]S1$, S2$) Group: String
Description: Return the index where S2$ first matches S1$. If no match is found return 0.

Parameter Description
Index Start searching for S2$ at this index in S1$. If this is omitted then start searching from the beginning of S1$.
S1$ Search for S2$ in this string value. If this value is Null then Null is returned.
S2$ Search S1$ for this string value. If this value is Null then Null is returned.


 Category Survey
AutoMate 6 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 04/22/2013 01:53 AM
User is offline View Users Profile Print this message

Author Icon
Barbar
Expert (100-199)

Posts: 110
Joined: 07/02/2007

hi
Few years have passed, and im still there looking for a solution.....
please help me to understand again (If u can give me the exact way ill be more than greatful).
I want to get the text after the 4th time "span class="label" apear in the text attached
how do I acheave that

Thank U
Bar

 Category Survey


http.txt
http.txt  (77 KB)

 04/22/2013 07:10 AM
User is offline View Users Profile Print this message

Author Icon
Leonard Amabile
HelpSystems

Posts: 5454
Joined: 05/15/2007

Hi Bar,

Using regex, you can get either result as I have outlined:

Step 5 Result:
Returns the 4th instance of the entire line found

Step 6 Result:
Returns value between the tags of the 4th instance of the entire line found

 Category Survey
AutoMate 6 version:
Windows version:



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------

Leonard Amabile | Director, Cross Platform Support
AutoMate | InterMapper | Skybot | Divisions of HelpSystems
T: +1.213.738.1700 | F: +1.213.738.7665
 04/22/2013 07:25 AM
User is offline View Users Profile Print this message

Author Icon
Barbar
Expert (100-199)

Posts: 110
Joined: 07/02/2007

Hi Leonard
I didnt really understood your way....
do U know if there is a way to take the text in a variable and to instruct to find the 4th time that the word appears

thank U
guy


 Category Survey
 04/22/2013 07:30 AM
User is offline View Users Profile Print this message

Author Icon
Leonard Amabile
HelpSystems

Posts: 5454
Joined: 05/15/2007

Hi Bar,

The task that I have provided looks for the fourth instance as you required. I have attached the .aml file to my reply. In my example, I am providing the string in a variable with many instances and showing you that I am only picking up the 4th instance. You can use what I have provided and search against that contents of your text file.

 Category Survey
AutoMate 6 version:
Windows version:





-------------------------

Leonard Amabile | Director, Cross Platform Support
AutoMate | InterMapper | Skybot | Divisions of HelpSystems
T: +1.213.738.1700 | F: +1.213.738.7665
 04/22/2013 07:52 AM
User is offline View Users Profile Print this message

Author Icon
Barbar
Expert (100-199)

Posts: 110
Joined: 07/02/2007

I'll try to understand your example

thank U

(will keep U informed)

 Category Survey
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 1006 guests browsing this forum, which makes a total of 1006 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog