![]() |
![]() |
We are currently migrating this forum over to our HelpSystems domain. Please post all new threads in our new HelpSystems Community Portal. |
![]() |
|
![]() |
AutoMate Discussion | ![]() |
Topic Title: Return a value based on the position of an another value in a string (array) Topic Summary: Created On: 10/16/2017 07:14 AM Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
||||||||||
Hi! Response:
So, if this variable contains "source":"TDT","format":"HTXML" I need to return the following two values: - on the left side - return the 8186 - on the right side - return 77775 Can anyone help? Much appreciated!! <....>,<....>,<return this value from left>,<....>,<....>,<if this value is here>,<....>,<....>,<return this value from right>,<....>,<....>
Edited: 10/16/2017 at 01:24 PM by DorelPureca |
||||||||||
|
||||||||||
![]() |
||||||||||
Hello Dorel,
Are you trying to replace, for example, "source" with "8186"? Or are you trying to grab the value of "source". If you are trying to replace, you can use the replace action to look for the specific word ,"source", and replacement with any text of your choosing... Here is more info on the replace action: http://www.networkautomation.c...ext/Text_-_Replace.htm
------------------------- ![]() Alex Escalante | Support Analyst AutoMate | Division of HelpSystems HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665 |
||||||||||
|
||||||||||
![]() |
||||||||||
Hi, Set %varA%= the text found 2 positions away on the left side of "source":"TDT","format":"HTXML" (8186) Set %varC%= the text found 2 positions away on the right side of "source":"TDT","format":"HTXML"(77775) *the position of "source":"TDT","format":"HTXML" is not fixed, it's always different. Check the image attached, maybe is more explainatory
Edited: 10/18/2017 at 01:21 AM by DorelPureca |
||||||||||
|
||||||||||
![]() |
||||||||||
Hi Dorel, This turned out to be more difficult than I thought it would be, but I created a task for you that parses these numbers. I hope this works in every case for you.
Here's a summary of what the task does: It finds text between { and }. In this case it found 6 strings. Loops through these strings and checks if any contain ""source":"TDT","format":"HTXML"". If it does, then it gets the id for that string and then it gets the id of the following string as well.
------------------------- ![]() Devin Cannon | Support Analyst AutoMate | Division of HelpSystems HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665 |
||||||||||
|
||||||||||
![]() |
||||||||||
Hey Devin, I managed to find only the number on the left, then I just put everything on pause, because finding the right one, was a bit tricky. But now, I tested your script and fits like a glov. Much appreciated!
|
||||||||||
|
FuseTalk Enterprise Edition v4.0 - © 1999-2021 FuseTalk Inc. All rights reserved.