You don't need regular expressions. Python has a built-in string method that does what you need:
mystring.replace(" ", "_")
Answer from rogeriopvl on Stack OverflowYou don't need regular expressions. Python has a built-in string method that does what you need:
mystring.replace(" ", "_")
Replacing spaces is fine, but I might suggest going a little further to handle other URL-hostile characters like question marks, apostrophes, exclamation points, etc.
Also note that the general consensus among SEO experts is that dashes are preferred to underscores in URLs.
import re
def urlify(s):
# Remove all non-word characters (everything except numbers and letters)
s = re.sub(r"[^\w\s]", '', s)
# Replace all runs of whitespace with a single dash
s = re.sub(r"\s+", '-', s)
return s
# Prints: I-cant-get-no-satisfaction"
print(urlify("I can't get no satisfaction!"))
Replace space with underscore using python - Stack Overflow
modelbuilder - Replace occasional Space with Underscore using Python parser of ArcGIS Field Calculator? - Geographic Information Systems Stack Exchange
How to replace space with underscores using a regex in EPLAN?
Replacing spaces in filenames with underscores('_')? How can it be done?
You don't necessarily have to define a function for this one. Try this:
str(!PlaceName!).replace(' ', '')
The "not defined" error is related to the lack of quotes around the NoSpace1. This could be from the % on either side of the Value. Your expression should be
ReplaceName(!Placename!)
You do not need the field calculator for replace at all.
You can just use the Find & Replace tool which is accessed from the attribute-table which has the search/replace function the same way as in Excel, for example.
It also works for all columns simultaneously or can be set to search for whole values etc.

Hey, guys. I’m a total newbie when it comes to regex and have no idea what I’m looking at, so I’m asking for your help. How can I replace spaces with underscores using a regex in EPLAN?
Example string: "This is a test" --> "This_is_a _test"
I also have an image of something else I’ve done where I removed '&E5/' from the string so that only "011" was left.
In EPLAN:
Where there are a Source Text and Output Text, one can put RegEx expressions.
Solution: