I am not clued up on Regex as much as I should be, so this may seem like a silly question.
I am splitting a string
into a string[]
with .Split(' ')
.
The purpose is to check the words, or replace any.
The problem I'm having now, is that for the word to be replaces, it has to be an exact match, but with the way I'm splitting it, there might be a (
or [
with the split word.
So far, to counter that, I'm using something like this:
formattedText.Replace(">", "> ").Replace("<", " <").Split(' ')
.
This works fine for now, but I want to incorporate more special chars, such as [;\\/:*?\"<>|&']
.
Is there a quicker way than the method of my replacing, such as Regex? I have a feeling my route is far from the best answer.
EDIT
This is an (example) string
would be replaced to
This is an ( example ) string