0

I want to find first character for example "A" if string have multiple A's i want only first one

Example : "bcAdeAnoA" i want only first "a" after bc

Dim test = "bcAdeAnoA"
Dim regex = New Regex("A", RegexOptions.IgnoreCase)
`then my code , replacing or do anything i want`
sample = regex.Replace(sample, "#")

Note: Regex is not necessary just giving a example

hewman
  • 47
  • 1
  • 6
  • Use the [count argument](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.replace?view=netcore-3.1#System_Text_RegularExpressions_Regex_Replace_System_String_System_String_System_Int32_) – Wiktor Stribiżew May 12 '20 at 22:35
  • Only first one is regex.Replace using "^([^a]*)a" where ignore case and replace with group 1 + #. I don't believe there is a range from, to so max replacement is useless with only a single purpose `[1]`, do it like this its better. –  May 12 '20 at 22:40
  • @Edward can you be more specific with link or previous answer – hewman May 12 '20 at 22:48
  • "^([^a]*)a" can only math once, first once –  May 12 '20 at 23:16

0 Answers0