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: Specific Number of characters after certain criteria
Topic Summary:
Created On: 04/08/2013 02:59 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.
Answer This question was answered by Liz Casale, on Tuesday, April 9, 2013 9:00 AM

Answer:
Hi RoRo,

Please review the following steps:

 04/08/2013 02:59 PM
User is offline View Users Profile Print this message

Author Icon
RoRo
Student (5-19 posts)

Posts: 8
Joined: 07/18/2012

Here is my scenario.  I'm reading from a file and in that file I have a long pipe delimited line.  The line looks like this :

 

AA-BB|CC-DD|EE-FF

 

I'm reading the and putting it into a variable.  I then need to search that variable for say CC- and if it finds it then grab the next two characters and throw it into a different variable.  In this case it would grab DD and populate it into said variable. 

I'm not sure the most efficient way to go about this.  I know that I could loop through the entire string based on the pipe and extract that method, but this string could be extremely long.  I think it'd be more efficient if I could just search for CC- and if it finds it grab the next two characters.  But I just don't know how to accomplish it in Automate.  Thanks for your help.

 04/09/2013 05:45 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

RoRo
the regular expression below grasps the two first characters following |CC-


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


-------------------------
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/09/2013 06:32 AM
User is offline View Users Profile Print this message

Author Icon
RoRo
Student (5-19 posts)

Posts: 8
Joined: 07/18/2012

Thank you Jean.  But would this work if CC- was stored in a variable?  I would not think so. The scenario is both the text to search through and the text to find are stored in variables.  So I couldn't hard code CC- and thus I believe that real expression would not work.

 04/09/2013 08:34 AM
User is offline View Users Profile Print this message

Author Icon
Liz Casale
AUTOMATE EMPLOYEE

Posts: 940
Joined: 05/23/2011

Answer Answer
Hi RoRo,

Please review the following steps:




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


-------------------------
Liz Casale
Technical Support Representative
(213) 738-6966
Network Automation, Inc.

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

AM5 5.5.5.1; AM6 6.2.8.0; AM7 7.1.3.0; AM8 8.0.9.0; AM9 9.0.3.4
BPA7 7.1.3.0; BPA8 8.0.9.0; BPA9 9.0.3.4
 04/09/2013 09:01 AM
User is offline View Users Profile Print this message

Author Icon
RoRo
Student (5-19 posts)

Posts: 8
Joined: 07/18/2012

That got me what I needed Liz.  Thanks a ton.

 04/09/2013 09:15 AM
User is offline View Users Profile Print this message

Author Icon
RoRo
Student (5-19 posts)

Posts: 8
Joined: 07/18/2012

Actually I spoke too soon.  That didn't work, but it's got me headed on the right path. 

 04/09/2013 09:31 AM
User is offline View Users Profile Print this message

Author Icon
RoRo
Student (5-19 posts)

Posts: 8
Joined: 07/18/2012

This is what I ended up doing if anyone searches this later down the line.  I used the index to find what I need.

 

<AMVARIABLE NAME="varLine">AA-BB|CC-DD|EE-FF</AMVARIABLE>
<AMVARIABLE NAME="varCC">EE-</AMVARIABLE>
<AMVARIABLE NAME="varEnd"></AMVARIABLE>
<AMVARIABLE NAME="myIndex"></AMVARIABLE>
<AMIF TEXT="%varLine%" SUBSTRING="%varCC%" INDEXVARIABLE="myIndex">
     <AMINCREMENTVARIABLE RESULTVARIABLE="myIndex" AMOUNT="3" />
     <AMTEXTGETSUBTEXT TEXT="%varLine%" STARTPOSITION="%myIndex%" LENGTH="2" RESULTVARIABLE="varEnd" />
     <AMSHOWDIALOG>var line %varLine%

var end %varEnd%</AMSHOWDIALOG>
</AMIF>

 04/10/2013 06:19 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

RoRo,
I see you got what you neede without a regular expression.
But to answer your question, you can also use variables (surrounded with %) inside regular expressions.
The variable is resolved before the regular expression is submitted.

-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
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 1290 guests browsing this forum, which makes a total of 1290 users using this forum.

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

Sitemap Network Automation Software Blog