Good afternoon Skyline,
I'd like to parse one property of a service and instead of using an automation script to parse it, I'd like to know if it was possible to do it in Visio.
If yes, could you please provide any documentation.
Thanks by advance,
Good afternoon Jarno,
The current state of the property I’d like to modify is the following :
– SITE_1=MUS, PORT_IRD1_SLOT_C1=Slot: 5 Port: A, RELATED_CI_1_C1=Mus-MTG-AppearTV02;SITE_2=SAF, PORT_IRD2_SLOT_C1=2, RELATED_CI_2_C1=SAF_MTG_IRD02
The expected state I’d like to retrieve under a shape is :
Mus-MTG-AppearTV02, 2, these are the 2 information I’d like to keep, one is related to RELATED_CI_1_C1=, the other one to PORT_IRD2_SLOT_C1=.
So far I am able to retrieve, Mus-MTG-AppearTV02 thanks to (?<=RELATED_CI_1_C1=).[^;]*
In the Regexplace, I am not sure to understand the parameter z "the string that will replace each of the matches". Could you please explain with different words ?
Thanks !
Hi Hugo,
You can make use of the 'RegexReplace' placeholder to apply a regular expression to the service property, without making use of an autoamtion script. This is documented in Placeholders for variables in shape data values | DataMiner Docs
In short, make following replacements within [RegexReplace:x,y,z]
x = regular expression
y = [property:yourservicepropertyname]
z = The string that will replace each of the matches.
Feel free to post more details on how exactly the property should be parsed, in case you need further feedback.
Note that you can use named capture groups in the RegexReplace placeholder, something which is very powerful: https://www.regular-expressions.info/named.html
Good evening Ruben !
I have this property containing the following string :
“SITE_1=MUS, PORT_IRD1_SLOT_C1=Slot: 5 Port: A, RELATED_CI_1_C1=Mus-MTG-AppearTV02;SITE_2=SAF, PORT_IRD2_SLOT_C1=2, RELATED_CI_2_C1=SAF_MTG_IRD02;”
I’d like to retrieve the element name (Mus-MTG-AppearTV02) which is related to (CI_1_C1) and display it in a shape.
In Visio I tried the following command with the data field of type “element” :
RegexReplace:(?<=RELATED_CI_1_C1=).[^;]*,Property[AbortMaintenance],z
But I don't get the use of the "z" : the string that will replace each of the matches. Could you explain please ?
Thanks for you time all !
Good afternoon Ruben,
Any update on the following topic ?
Thanks by advance !
Hi Hugo,
I'm replying in a new post so that I can include a screenshot, and because there are multiple things at play here, that require an explanation...
The "z" part of the shape data will replace the text that matches with the regex.
I'm not too experienced with regular expressions myself, so someone might provide better alternatives, but for the scenario you describe below, I would typically work with capturing groups.
The idea is that you define a regex which matches with the entire text (ie the property), and specify a capturing group that contains the text you want to filter out. The "z" part can then reference that capturing group.
Practical example, based on what you have so far:
Regex: .*RELATED_CI_1_C1=(.*?);.*
If you enter this in a regex tester (ie regexr.com), you'll get:
As you can see, this matches with the entire string (see Match 0), and we also have a capturing group 'Group 1', which contains the result you're after.
The shape data then becomes:
[RegexReplace:.*RELATED_CI_1_C1=(.*?);.*,[Property:AbortMaintenance],$1]$1 refers the the first capturing group 'Group 1'.
Translated: Replace the entire string with the result of the first capturing group.
There is however still a problem with this. Because Visual Overview uses the comma character to separate the x,y,z parts of the shape data, and your property also contains multiple commas, this will not be processed correctly.
To work around this, we need to specify a custom separator, ie the character #, which does not occur in the property value or regular expression. The syntax for this is [Sep:,#].
Translated: replace separator ',' with '#'.
The final shape data then becomes:
[RegexReplace:[Sep:,#].*RELATED_CI_1_C1=(.*?);.*#[Property:AbortMaintenance]#$1]Hope that helps!
Hi Hugo, what actions do you exactly mean with ‘Parse’, i.e. what is your current state and expected state?