Skale
asked on
How to apply Regex.Match for my string structure in C#
Hello,
I'd like to parse part1 and part2 name from my below string structure with Regex.Match.
I don't know it can be appliable but my string is like below;
$J_____dummy_part1_to_part 2_sometext
if it's not matching i'd like return string.empty for part1 and part2
Any help would be great!.
Thanks.
I'd like to parse part1 and part2 name from my below string structure with Regex.Match.
I don't know it can be appliable but my string is like below;
$J_____dummy_part1_to_part
if it's not matching i'd like return string.empty for part1 and part2
Any help would be great!.
Thanks.
ASKER
Hi louisfr ,
I made a minor change and it worked as i would like:
var match = Regex.Match(input, @"(?:^\$J_____dummy_(.*?)_ to_(.*?)_( .*?)$)?");
also i would like to ask you is there any chance to implement a code to this single line to scope a cases like below;
$J_____dummy_part1_to_part 2
Thank you again.
I made a minor change and it worked as i would like:
var match = Regex.Match(input, @"(?:^\$J_____dummy_(.*?)_
also i would like to ask you is there any chance to implement a code to this single line to scope a cases like below;
$J_____dummy_part1_to_part
Thank you again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
First option:
Open in new window
Second option:Open in new window