Regex replacing

I am trying to learn Regex but I can not wrap my head around a problem that I encountered. I am looking up a name on Wikipedia using the roman alphabet, and I want to extract data written in Japanese kanji.
For example, this section on wikipedia, I have managed to only get the data within “()”, but with the current Regex I have written I am only available to get the first character of the data inside of “()”.

This is an example of the Wikipedia result:

“Yuta Taki (滝 裕太, Taki Yuta, born August 29, 1999) is a Japanese football player.”

Result I wish to grab using Regex or similar solution:

滝 裕太

The current Regex I am using is:
system.Text.RegularExpressions.Regex.Match(googleName,"\w").ToString
and what I manage to get from that is only:

If more information is needed please let me know because I would really like to know how to solve this!

Hi,

if your string is “Yuta Taki ( 滝 裕太 , Taki Yuta, born August 29, 1999) is a Japanese football player.”, the following helps you.

System.Text.RegularExpressions.Regex.Match(text,"(?<=\()[\w\s]+").Value

If your string is " 滝 裕太 , Taki Yuta, born August 29, 1999", the following will also work.

System.Text.RegularExpressions.Regex.Match(text,"^[\w\s]+").Value

Regards,

1 Like

Hello

If you are learning Regex,

Check out my Regex MEGAPOST.

2 Likes

@Yoichi

Thank you for your quick response and also for providing me with 2 different solutions.
I will try both of them out and see which one works the best with what I am trying to create and get back to you whether it works as I have thought or not!

1 Like

Hi again

Thanks again for providing a sample and the output. Could you tell us more about the pattern…

If the pattern is 100% consistent then you could try this solution:
Regex pattern:
(?<=()(.*), .*, .*\d+, \d{4}(?=))
Regex101.com link


To get Group 1:
INSERTVARIABLE(0).Groups(1).ToString

From the Matches Activity, use a write line activity (or an assign activity) and update the capital letters above with the Result from the Matches Activity.

@Yoichi

Sorry for the late response, I totally forgot!

I added the first solution you sent me to my automation and it works like a charm. Thank you so much for your help and and teaching, and I will make sure to study more Regex on my own so I can solve these kind of problems by myself in the future!

Best regards
Robert

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.