I'd do:

  • Find: @(\w+)@
  • Replace: ${$1}

Check Regular expression.

Explanation:

@       : literally @
(       : start group 1
  \w+   : 1 or more word character
)       : end group 1
@       : literally @
Answer from Toto on Stack Exchange
🌐
Stack Overflow
stackoverflow.com › questions › 53467157 › replace-specific-characters-in-string-using-regex
java - Replace specific characters in string using regex - Stack Overflow
For this a regex is not suitable, because there is no simple criterion for where to separate. String str2 = str1 .replaceAll("([0-9])(?=[A-Z])", "$1 ") //1 .replaceAll("\\bAND\\b", "&") //2 .replaceAll("\\bOR\\b", "|") //3 .replaceAll("(?<![=<>!])=(?!=)", "==") //4 .replaceAll("<>", "!=") //5 .replaceAll("(?<=[^&| ])(==|!=|&|\\)|\\|)", " $1") //6 .replaceAll("(==|!=|&|\\(|\\)|\\|)(?=[^ &|])", "$1 "); //7
🌐
Regular-Expressions.info
regular-expressions.info › replacetutorial.html
Replacement Strings Tutorial
Escaping rules may get a bit complicated when using replacement strings in software source code. ... Non-printable characters such as control characters and special spacing or line break characters are easier to enter using control character escapes or hexadecimal escapes. ... Reinserting the entire regex match into the replacement text allows a search-and-replace to insert text before and after regular expression matches without really replacing anything.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-string-replace-example-with-regex
JavaScript String.Replace() Example with RegEx
October 20, 2020 - With RegEx, you can match strings at points that match specific characters (for example, JavaScript) or patterns (for example, NumberStringSymbol - 3a&). The .replace method is used on strings in JavaScript to replace parts of string with characters.
🌐
JetBrains
jetbrains.com › help › phpstorm › tutorial-finding-and-replacing-text-using-regular-expressions.html
Find and replace text using regular expressions | PhpStorm Documentation
June 17, 2026 - When you want to search and replace specific patterns of text, use regular expressions. They can help you in pattern matching, parsing, filtering of results, and so on. Once you learn the regex syntax, you can use it for almost any language.
🌐
C# Corner
c-sharpcorner.com › blogs › replace-special-characters-from-string-using-regex1
Replace Special Characters from string using Regex
February 18, 2015 - Regex.Replace(your String, @"[^0-9a-zA-Z]+", "") This code will remove all of the special characters but if you doesn't want to remove some of the special character for e.g.
🌐
Quora
quora.com › How-do-I-replace-a-specific-character-after-the-occurrence-of-a-string-using-regex
How to replace a specific character after the occurrence of a string using regex - Quora
Answer: The answer will vary slightly based on which tool you are using but let’s take sed as an example. Assume your input.txt somethingand nothing. everythingXYZxyz anytingEFGefg To replace the character after “thing” with X sed -e ‘s/thing.\(.*\)/X\1/’ Explanation: The expression ...
🌐
CodingTechRoom
codingtechroom.com › question › replace-specific-characters-in-string-using-regex
How to Replace Specific Characters in a String Using Regex in Programming - CodingTechRoom
# Replace 'o' and 'a' with 'X' modified_string = re.sub(r'[oa]', 'X', original_string) # Result: 'GXXd mXrning, everyXne! It's X beXutiful dXy.' Understanding regex syntax and patterns can be overwhelming for beginners. Not accounting for special regex characters that may affect matching.
Find elsewhere
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python regex replace special characters
Python regex replace special characters - Spark By {Examples}
May 31, 2024 - How to replace special characters in Python using regex? As you are working with strings, you might find yourself in a situation where you want to replace
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › standard › base-types › substitutions-in-regular-expressions
Substitutions in Regular Expressions - .NET | Microsoft Learn
They use a regular expression pattern to define all or part of the text that is to replace matched text in the input string. The replacement pattern can consist of one or more substitutions along with literal characters. Replacement patterns are provided to overloads of the Regex.Replace method that have a replacement parameter and to the Match.Result method.
🌐
Highbond
help.highbond.com › helpdocs › analytics › 15 › en-us › Content › analytics › scripting › functions › r_regexreplace.htm
REGEXREPLACE( ) function - HighBond
Use REGEXREPLACE( ) any time you want to find and replace data in Analytics using simple or complex pattern matching. You can use the $int element to replace characters with themselves, which allows you to preserve the meaningful parts of data, while standardizing or omitting surrounding or ...
🌐
TutorialsPoint
tutorialspoint.com › article › javascript-regex-how-to-replace-special-characters
JavaScript regex - How to replace special characters?
The replace() method with regex patterns provides a powerful way to remove or replace special characters in JavaScript strings. Use /[^a-zA-Z0-9]/g to remove all special characters or create custom patterns for specific requirements.
🌐
Oracle
docs.oracle.com › en › middleware › enterprise-data-quality › 12.2.1.3 › edqoh › regex-replace.html
RegEx Replace
The RegEx Replace processor provides a way to perform advanced text replacements by matching String or String Array attributes to a regular expression, and replacing the matching value with a specific value, or with a value derived from the matched text - for example replacing the whole of a string that matched a regular expression with only the first group in the expression.
🌐
Highbond
help.highbond.com › helpdocs › analytics › 151 › en-us › Content › analytics › scripting › functions › r_regexreplace.htm
REGEXREPLACE( ) function
March 17, 2022 - Replaces all instances of strings matching a regular expression with a new string. ... Returns the character field data with the spacing between words standardized on a single space. Using the BLANKS( ) function in new_string, rather than a literal space, makes spaces easier to read and less ...
🌐
CodingTechRoom
codingtechroom.com › question › -replace-characters-using-regular-expressions
How to Replace Characters Using Regular Expressions Based on Matches Between Strings? - CodingTechRoom
Solution: Always escape special characters if they're part of the character class. Mistake: Forgetting to use the global flag in regex (g). Solution: Add 'g' at the end of new RegExp() to replace all instances.
Top answer
1 of 2
1

In your case there are a couple of easy solutions. This first solution uses only basic regex:

[\.\w]+$

This captures every word character \w or period \. from the end $, stopping when it reaches any other type of character. This works because the space is not a word character or a period.

If you would like to select the region you want to remove, you can just use:

.*

Read this as match every character .* until the last space . The reason this matches until the last space, is because the star is a greedy quantifier. This means it matches everything it can, then starts giving back characters as needed for the rest of the pattern to match. To match until the first space, use .*? . The question mark next to the star makes the star lazy. This means the star will match as little as it has to in order for the next part of the expression to find a match.

However, capture groups are ideal for problems like this, where you would like to remove part of a line and keep the rest. A simple formula for this is:

^(.*)pattern_to_remove(.*)$

You can then recover the rest using backreferences. These store the capture groups (anything in parenthesis) from you regex into preset variables. In the pattern above, this would be \1\2 or $1$2 depending on the language you are using. This brings me to probably the easiest answer to your problem:

(.*)

The first capture group contains everything after the space. This regex is very straightforward and easy to read. Move to the first space , then capture everything after (.*).

For a comprehensive reference on regex, check out regular-expressions.info. Here is a link to the page on capture groups.

2 of 2
0
  • Ctrl+H
  • Find what: ^\S+\h+
  • Replace with: LEAVE EMPTY
  • CHECK Wrap around
  • CHECK Regular expression
  • Replace all

Explanation:

^         # beginning of line
  \S+       # 1 or more non spaces
  \h+       # 1 or more horizontal spaces

Screenshot (before):

Screenshot (after):

🌐
MathWorks
mathworks.com › matlab › language fundamentals › data types › characters and strings
regexprep - Replace text using regular expression - MATLAB
Insert text at the beginning of a character vector using the '^' operator, which returns a zero-length match, and the 'emptymatch' keyword. str = 'abc'; expression = '^'; replace = '__'; newStr = regexprep(str,expression,replace,'emptymatch') ... Text to update, specified as a character vector, ...