4-8 字串?代??

eX`гqΦAHΦpQγqΦӤΩSwrA`NЦpQγqΦӶirꪺNADnOO regexprepCҦpAYnNҦub M t ܤ֧@ӥvrN xxxAiUCdҡG

Example 1: 04-qιB⦡/regExpRep01.mstr = 'I bet there is a bat in the boat!'; pat = 'b[aeiou]+t'; newStr = regexprep(str, pat, 'xxx'); fprintf('%s\n', newStr);I xxx there is a xxx in the xxx!

t@ӽdҡAhON@CrꤤAsX{hӪťզrAY@ӪťզrApUG

Example 2: 04-qιB⦡/regExpRep02.mstring = 'Draft beer, not people.'; pattern = '\s+'; string2 = regexprep(string, pattern, ' '); % NhӪťY@ fprintf('rG%s\n', string); fprintf('קG%s\n', string2);rGDraft beer, not people. קGDraft beer, not people.

bϥ regexprep irNL{A MATLAB iHNpA쪺lrȮxsܼ $1, $2, $3 AHKBzA^rAҦpG

Example 3: 04-qιB⦡/regExpRep03.mstr = 'I walk up, he walks up, we are all walking up.'; pat = 'walk(\w*) up'; newStr = regexprep(str, pat, 'sleep$1 tight'); fprintf('%s\n', newStr);I sleep tight, he sleeps tight, we are all sleeping tight.

ϥkAڭ̤]iHN@Ӧrꪺeӭ^rաApUG

Example 4: 04-qιB⦡/regExpRep04.mstr = 'are you ready'; pat = '^([^ ]+) +([^ ]+)'; rep = '$2 $1'; str2 = regexprep(str, pat, rep); fprintf('rG%s\n', str); fprintf('קG%s\n', str2);rGare you ready קGyou are ready

bϥ regexprep OɡAiHbĥ|ӿJܼƿJLrAHNPN覡CҦpAignorecase NiHiujpgvPNAonce NuNĤ@ӤŦXrALﶵЬd regexprep uW䴩]b MATLAB Judoc regexprepvYiܽuW䴩^C


MATLAB{]pGig