Created
December 19, 2022 03:30
-
-
Save chuongmep/89df59e9a837ce48de9916139d069ad6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string pattern = @"_detached.*"; | |
string replacement = ""; | |
Regex rgx = new Regex(pattern); | |
fileName = rgx.Replace(fileName, replacement); | |
if (fileName.EndsWith(".rvt")) fileName = fileName.Replace(".rvt", String.Empty); | |
Source_File_Rvt = filename; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
test = ["dadaa__detached_1","dadaa__detached_3","dadaa__detached_2"] | |
# pattern regex to match the string with _detached and remove all _detached and all characters after it | |
pattern = re.compile(r'_detached.*') | |
# replace the string with empty string | |
test = [pattern.sub('', i) for i in test] | |
# print the list | |
print(test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment