I have multiple strings that looks:
this is ab-skdn string
ab-sdhnif my string
For each string, I need to pull the part that is ab-** For example I need ab-skdn and ab-sdhnif
How could I do that using C#
My code would look like something:
var myString = "this is ab-skdn string"
match = "ab-skdn"
CodePudding user response:
Use a regex to find the matches. A simple regex that does what you need is:
ab-[a-z]*
Since you didn't provide any code I can't provide an example for how to use a regex in your context, but there are plenty of examples out there. A quick google search on how to use Regex in C# should get you started. The link I provided also has some good examples.