I have a broad set of text like so:
- "Hello there. Are you interested in a holiday in New York, then contact [email protected]. Let us help you."
- "Hey mr! Are you interested in a holiday in LA, then contact [email protected]. We got you!"
- "Welcome to our humbo home. Are you interested in a holiday in France, then contact [email protected]. See you soon!"
I want to remove the string " Are you interested in a holiday in <place>, then contact <email>."
Here I don't know how many characters <place> has or what exactly the value of <email> is.
The result would be:
- "Hello there. Let us help you."
- "Hey mr! We got you!"
- "Welcome to our humbo home. See you soon!"
I've been trying out and googling for regex replacements with placeholders, but I only find INSERTING values with regex and string.format examples, but nothing on replacing values.
I looked here, but in this sample there are already placeholders in the source text.
I also checked here and tested to replace at least the <place>:
txt = Regex.Replace(txt, " Are you interested in a holiday in \d+\.?\d*%;, then", "")
txt = Regex.Replace(txt, " Are you interested in a holiday in \\d+\\.?\\d*%;, then", "")
But nothing gets replaced.
How can I replace the source string that has dynamic and values?
\d+\.?\d*%matches percentage values. Why not try.*?as mentioned in the question you referred to? Any email is usually 1+ non-whitespace chars,@and again some non-whitespace, so\S+@\S+(of course, it is a simplification, but there are a lot of examples of more restrictive patterns online). At any rate, the pattern to match any text is.*?, try this (withRegexOptions.Singlelineoption).