简体   繁体   中英

Find and replace inside regex result in Excel VB

After much frustration and reading documentation I still can't seem to find the way to run a search for a regex pattern and replace characters inside all the matches in the spreadsheet for that pattern.

I have this content in a cell:

$test string[0] = "this is a test string."; $another test string[431] = "yet another test string";

This is my regex pattern:

"\$(.*?)\["

outputs:

test string, another test string

I need to find all the matches and replace the space for a hyphen in order for the output to be:

test-string, another-test-string

Any ideas on how to do this?

Thanks in advance!

我想您可以使用积极的前瞻功能,即:

ResultString = Regex.Replace(SubjectString, "(?<=\$.*?) (?=.*?\[)", "-")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM