I have a field PORT_DESC with the values as:
"somethings sdsa Device:XYZ PORT: 1.2.3 BackPort: 4.5.6 some other text"
"somethings Othertext Device: PORT: BackPort: some other text"
Now I need to define a Port_Flag separating these values as:
eval Port_Flag= case(like(PORT_DESC,"%PORT: BackPort:%"), "Flag_NO",like(PORT_DESC,"%PORT: 1.2.3 BackPort:%"),"Flag_YES",1=1,"Other")
However, the Port value can be anything such as 1.2.3 or CRMT or vw3d.
How can I separate these values where either no Port value is given or some value is assigned? Any regular expression will also be a great help, which can define
PORT:[Anything 0-9 or A-Z or a-z $%&/()] BackPort:
Thanks in advance.
Instead of using
like in your
case statement, use
match function accepts regular expressions. For example,
eval Port_Flag= case(match(PORT_DESC,"PORT: BackPort:.*"), "Flag_NO", match(PORT_DESC,"PORT: .*? BackPort:.*"), "Flag_YES",1=1,"Other")