Event Rule - Regular Expression to remove a certain part of the String
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 12:08 PM
Hi There,
I am trying to write a regular expression in the event rule Transform section. I am getting extra characters in FQDN and i am trying to remove them.
The example strings are :
abcd-asm.vdcunix.local
abcdasm.vdcunix.local
i am trying to remove asm and -asm from the string. I used (\|*-asm|asm\|*) but it is returning as Unknown .
Expected outputs is: abcd.vdcunix.local
Kindly help me with expression here.
- Labels:
-
Event Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 12:21 PM
Hello Ashok!
Try the following:
var originalString = 'abcd-asm.vdcunix.local';
var goodString = originalString.replace(/asm|-asm/, '');
gs.print(goodString);
You can change the first string variable to different strings to confirm it works.
Try running it in System Definition > Scripts - Background
Hope that helps!
If it did, please mark as Helpful and consider setting the reply as the Correct Answer to the question, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 12:27 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 12:28 PM
I don't believe event rules allow for coding. This poses a problem as complex if then or is not allowed.
I have found that I need to glob multiple parts then reassemble using the variables pulled from the regex. Examples:
(.*)asm(.*)
and
(.*)-asm(.*)
Name the variables for the data globbed the params and then combine them back in the field of your choosing.
Example
$var1$var2
You will need two rules to remove the "-asm" and the "asm". The filter for the first rule would need to have the search for "-asm" at a lower sort order so that it is tried first. If the field you are filtering on does not have "-asm" in it then it would be picked up by the next filter using just "asm"
The rules would be identical wit hthe exception of one filtering on a match of "-asm" and one filtering on a match of just asm. This is to allow the regex to work for each format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 12:49 PM
Thanks Patrick this helps alot. Do you think is there any way to remove the asm and-asm by writing expression?