How to use regex that checks or compare the output if that words are the same in the file? I need a scenario that checks the word if existing or not.
For exampe:
A11BC
D1C0H
SP2gt
QKq12
How to use regex that checks or compare the output if that words are the same in the file? I need a scenario that checks the word if existing or not.
For exampe:
A11BC
D1C0H
SP2gt
QKq12
Hi,
If you need to check if either of the above words exists in your string, the following will help you.
System.Text.RegularExpressions.Regex.IsMatch(yourString,"\b(A11BC|D1C0H|SP2gt|QKq12)\b")
This returns true or false.
If you need to check the above single word, the following will work.
System.Text.RegularExpressions.Regex.IsMatch(yourString,"\b(A11BC|D1C0H|SP2gt|QKq12)\b")
If the above doesn’t fit for you, can you elaborate your requirement?
Regards,
I need scenario like this
For example, I have txt. file and inside of the file there’s a value like this:
2022-20-11 ステータス:完了
2022-20-11 名称: NX 4497-AE
2022-20-11 ID: 80 g 2-92 Ad 002 p-978 x 2
2022-20-11 ステータス:完了
2022-20-11 名称: NP 2012-2 E
2022-20-11 ID:0597 a 479725 e-14 tx 21
2022-20-11 ステータス:完了
2022-20-11 名前: AP 5594-R 5
2022-20-11 ID: a 889-4698 Epp 2-1 pp 1 a 2
NOTE: What I need to do is to create a scenario or activity that can read the file and its data using regex. But I only need to get are the Name, ID, and its corresponding value. Also, to check if those Name, ID, and Value was existing, if not then throw.
Hi,
Is your input data Japanese?
Anyway, can you try the following sample?
This extract each data by each item.
Sample20221122-4.zip (2.7 KB)
Regards,
Yes, my input data are Japanese. Okay, I will try that. I raised a question if I encounter blockers. Thanks
I only need to get is this with the corresponding value:
名称:
ID:
Hi,
In the above sample,
item.Gropup("Name").Value
returns content of 名称
and
item.Gropup("ID").Value
returns content of ID
Or, do you also need value including "名称: " , for example?
Regards,
Yes, I also need a value including "名称: " and “ID:”
Hi,
How about inforamtion for datetime? Do you need whole the line?
Regards,
Yes, I need the whole line including datetime and here’s another example and use this example:
Note: for example, I have many VM names and UUID with different names and uuids all I need to do is to check it if they are existing, using regex. But only you need to apply is this “VM作成完了 VM名” and “UUID取得完了 UUID” and get their corresponding value
2022-20-11 ステータス:完了
2022-20-11 名称: NX 4497-AE
2022-20-11 ID: 80 g 2-92 Ad 002 p-978 x 2
2022-20-11 ステータス:完了
2022-20-11 名称: NP 2012-2 E
2022-20-11 ID:0597 a 479725 e-14 tx 21
2022-20-11 ステータス:完了
2022-20-11 名前: AP 5594-R 5
2022-20-11 ID: a 889-4698 Epp 2-1 pp 1 a 2
Thanks,
Ally
HI,
If you need to extract whole the line which has keyword, the following might be better.
This return line which has each item of keywords variable. Can you try this?
Sample20221122-4v2.zip (4.5 KB)
Regards,
Wait @Yoichi how about this scenario I have a text file and there’s a value like that I need to read and get that data inside of a text file?
Hi,
We can easily read text from a file using ReadTextFile Activty as the following.
Can you check the following sample?
Sample20221122-4v3.zip (4.7 KB)
Regards,
Hi,
First, can you check the data is read correctly. Please note that it might be necessary to set proper character encoding if your input is Japanese.
Regards,
I already check the data it read correctly