Here is an answer using regex as the OP asked.

To use regex, put the replacment text in a match ( ) and then replace that match with nothing string.Empty:

string text = @"werfds_tyer.abc.zip.ytu_20111223170226_20111222.20111222";
string pattern = @"(\.zip\.ytu)";

Console.WriteLine( Regex.Replace(text, pattern, string.Empty ));

// Outputs 
// werfds_tyer.abc_20111223170226_20111222.20111222
Answer from ΩmegaMan on Stack Overflow
🌐
Ablebits
ablebits.com › ablebits blog › excel › regex › regex to remove certain characters or text in excel
Excel Regex to remove certain characters or text from strings
August 22, 2023 - As mentioned above, to remove parts of text matching a pattern, you are to replace them with an empty string. So, a generic formula takes this shape: RegExpReplace(text, pattern, "", [instance_num], [match_case])
Discussions

Using regex to remove non-alphabetical characters in a string.
if a pattern matches things you want to keep, like "all letters": [a-zA-Z] you can invert it with "^" to make it "not" those things: [^a-zA-Z] also, there are (depending on which language and which regex variant you're using) shortcuts like \s = a space (or tab or newline or...) \S = not a space \w = a word type character (i.e. a-z A-Z 0-9 etc) \W = not a word type character \d = a number \D = not a number More on reddit.com
🌐 r/learnprogramming
7
1
July 24, 2021
regex - Remove a leading string using regular expression - Stack Overflow
I need to build one RegEx to remove leading "The" or "A" or "An" and "spaces" from a given string. For example, the given string is: The quick brown fox jumps over the lazy dog With Regex I w... More on stackoverflow.com
🌐 stackoverflow.com
How to remove a string of text with Regex tool?
Hi everyone, I have been using 'Text to Column' tool and that has been working fine but I really want to get into using the 'Regex' tool because of its capabilities. Granted I'm a novice at this so a lot of trials and errors to get things to work but for the life of me I can't figure out how ... More on community.alteryx.com
🌐 community.alteryx.com
November 29, 2017
Replace or remove a portion of string with a regex
Hi collegues, I have this string ... output: 17 So I have thought about using the string replacer node or the string manipulation node, but I don't have a clear idea of how to build a regex for remove or replace every characters after the : Someone has an idea?... More on forum.knime.com
🌐 forum.knime.com
0
1
September 14, 2017
🌐
Keyboard Maestro
forum.keyboardmaestro.com › questions & suggestions
Delete text after pattern (with RegEx) - Questions & Suggestions - Keyboard Maestro Discourse
November 10, 2023 - I'm still learning RegEx as I use it with some macros, but I ended up with this expression to delete everything after a certain word or group of words feat.*$ So this: "Bad Dreams feat. Emma Dean" (ignore the quotes) Becomes this: "Bad Dreams " (with the extra space at the end) Also, if I want to delete a space from the beginning, I used \sfeat.*$ "Bad Dreams feat.
🌐
JMP User Community
community.jmp.com › t5 › Discussions › Regex-to-remove-text-from-string › td-p › 650510
Solved: Regex to remove text from string - JMP User Community
June 22, 2023 - Is there a modification that would return the list and only remove the "not detected"? ... Names Default To Here(1); str = "item A, item B not detected"; return1 = Regex(Substitute(str, "not detected", ""), "\S*"); return2 = Substitute(str, "not detected", ""); return3 = Words(Substitute(str, " not detected", ""), ","); show(return1, return2, return3);
🌐
Bobby Hadz
bobbyhadz.com › blog › python-remove-regex-from-string
Remove characters matching Regex from a String in Python | bobbyhadz
April 9, 2024 - Use the re.sub() method to remove the characters that match a regex from a string.
🌐
Regex Tester
regextester.com › 102708
Remove string - Regex Tester/Debugger
Undo & Redo with {{getCtrlKey()}}-Z / Y. Search for & rate Community patterns. ... extended (x) extra (X) single line (s) unicode (u) Ungreedy (U) Anchored (A) dup subpattern names(J) Matches all except for a specific string, then reconstructs using substitution
🌐
Tidyverse
stringr.tidyverse.org › reference › str_remove.html
Remove matched patterns — str_remove • stringr
A character vector the same length as string/pattern. ... fruits <- c("one apple", "two pears", "three bananas") str_remove(fruits, "[aeiou]") #> [1] "ne apple" "tw pears" "thre bananas" str_remove_all(fruits, "[aeiou]") #> [1] "n ppl" "tw prs" "thr bnns"
Find elsewhere
🌐
iAm_ManCat Blog
iammancat.dev › home › remove characters from strings using regex in power apps
Remove characters from strings using Regex in Power Apps - iAm_ManCat Blog
March 17, 2023 - This can be used to validate and change strings based on the rules set out by the Regex string. In this example, We start by defining a group with an open round bracket, then we define a character section using a square bracket, then I am only going to allow Characters A-Z (Uppercase letters) and Characters a-z (lowercase letters) and Characters 0-9 (all numbers) and the ‘space’ character, then we close that section with a close square bracket and close the group with a close round bracket. ... If we want to remove characters from strings but have it done automatically, there are a few ways to do this.
🌐
Reddit
reddit.com › r/learnprogramming › using regex to remove non-alphabetical characters in a string.
r/learnprogramming on Reddit: Using regex to remove non-alphabetical characters in a string.
July 24, 2021 -

Hi, I am trying to remove non-alphabetical characters from the following string.

let string = "Anne, I vote more cars race Rome-to-Vienna"

I can get the result I am looking for with the following...

let newString = string.toLowerCase().split('').filter(el => el !== ' ' && el !== '-' && el !== ',').join('')

However I would prefer to use a much shorter piece of code using regex. I have gone over a few regex examples and tutorials but it still kind of confused me. Does anybody know the simplest way to remove the unwanted characters from the above string?

Thanks!!!

🌐
Alteryx Community
community.alteryx.com › t5 › Alteryx-Designer-Desktop-Discussions › How-to-use-RegEx-to-remove-text-in-a-string-and-replace-text › td-p › 55794
How to use RegEx to remove text in a string and replace text with the updated expression
June 13, 2024 - Thanks for the quick response! Both options worked. Using the RegEx tool the Regular Expression would be (.*)T(.*)\..* with the output method as Replace and the Replacement Text set to $1 $2.
🌐
Laserfiche Answers
answers.laserfiche.com › questions › 71779 › What-is-the-regular-expression-to-remove-the-string-abc-from-a-token
What is the regular expression to remove the string "abc\" from a token? - Laserfiche Answers
February 19, 2015 - \. : The period, escaped. In a regex, a period character by itself is used to symbolize a wildcard; as in, it can represent any character. By using a slash, "\", you tell the regex you want to match exactly the period character.
🌐
Alteryx
community.alteryx.com › home › participate › discussions › alteryx one
How to remove a string of text with Regex tool? - Alteryx
November 29, 2017 - Hi everyone, I have been using 'Text to Column' tool and that has been working fine but I really want to get into using the 'Regex' tool because of its capabilities. Granted I'm a novice at this so a lot of trials and errors to get things to work but for the life of me I can't figure out how ...
🌐
KNIME Community
forum.knime.com › knime analytics platform
Replace or remove a portion of string with a regex - KNIME Analytics Platform - KNIME Forum Archive
September 14, 2017 - Hi collegues, I have this string composed by hour, minute and seconds, here an example: 17:24:55 And I would like to remove the part after the : character and maintain only the hour part, as in this result output: 17 S…
🌐
Reddit
reddit.com › r/askprogramming › how do i remove a variable word from a string and the space and/or symbol that follows it using regex?
r/AskProgramming on Reddit: How do I remove a variable word from a string and the space and/or symbol that follows it using Regex?
November 17, 2022 -

I'm trying to remove a word from a string along with anything that goes after it so that the string doesn't have double spaces and/or random symbols in place of the removed word. Can I do this with regex in C#?

I haven't found a way online to use a variable pattern and do regex formatting on it to get the symbol that follows it, whitespace or whatever it might be. Doesn't help that I don't understand the Regex regular expressions.

Still learning C#/programming so I have no clue how to achieve this, this is what I wrote if it were the same syntax as Console.WriteLine():

/** Removes given word from line
@ param line – original text line (string)
@ param remove – word to remove   */
public static string RemoveWords (string line, string remove)
{
string punctuation = " [\\s,.;:!?()\\-]+";
string pattern = ("{0}{1}", remove, punctuation);      // the pattern that I have no idea on how to format
Regex rgx = new Regex(pattern);
string newLine = rgx.Replace(line, string.Empty);

return newLine;
}

Would really appreciate any help!

Edit: Solved, syntax I ended up needing was Regex.Escape():

        /** Removes given word from line
         @ param line – original line
         @ param remove – word to remove   */

        public static string RemoveWords(string line, string remove)
        {
            string newLine = Regex.Replace(line, @"\b" + Regex.Escape(remove) + @"\b[^a-zA-z]", "");

            newLine = Regex.Replace(newLine, @"\b" + Regex.Escape(remove) + @"\b", "");

            return newLine;
        }

🌐
UiPath Community
forum.uipath.com › help
Regular Expression - Remove Part Of A String - Help - UiPath Community Forum
August 21, 2019 - I have a string in the variable “person”. E.G “John Smith JP606060D 01/01/2019 Male” I want to remove all dates from the string. The date is different in each occurance of person. I’ve tried using: RegEx.Replace(person.ToString.Trim,“^([0-2][0-9]|(3)[0-1])(/)(((0)[0-9])|((1)[0-2]))(/)\d{4}$”,“”) but, this only removes the date if the string is “01/01/2019”, but not if it is within a larger string as per the example above Can anyone assist please?
🌐
Regex101
regex101.com › r › gJ6oZ6 › 1
regex101: Remove all special chars from string
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.