F
Fencer
Hello, say I have this string
abcde123:dsdls:dlsds
and I wanted to use regular expressions to extract abcde123.
In python I could do:
In C#, however, when I use:
Regex.Match("^([^:]*)", "abcde123:dsdls:dlsds")
The Match object m returned has the property Success set to False and
there's just an empty string in m.Groups[1].
I know there other (better) ways of extracting the particular substring
in this example, but I'm still wondering why it didn't work in C# and,
based on the Python code, how I should rewrite the C# version?
I've just returned to C# after being away for a long time so I'm very
rusty indeed (and I didn't know it all that well before, either).
Thanks!
- Fencer
abcde123:dsdls:dlsds
and I wanted to use regular expressions to extract abcde123.
In python I could do:
abcde123str = 'abcde123:dsdls:dlsds'
import re
matches = re.match('^([^:]*)', str)
print matches.group(1)
In C#, however, when I use:
Regex.Match("^([^:]*)", "abcde123:dsdls:dlsds")
The Match object m returned has the property Success set to False and
there's just an empty string in m.Groups[1].
I know there other (better) ways of extracting the particular substring
in this example, but I'm still wondering why it didn't work in C# and,
based on the Python code, how I should rewrite the C# version?
I've just returned to C# after being away for a long time so I'm very
rusty indeed (and I didn't know it all that well before, either).
Thanks!
- Fencer