How to find all letters before a character in a char variable
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to find a message hidden in a bunch of random characters. I have this secret message and I know that all the words are spaced inbetween the '#' character. I have been trying to use the regexp to find all the letters in between every '#'
secretMes = ';,.T234h467e#i`12n390@%f&^%o1@45r1%^m]\a131@t2i*/-o+/1n#i*895n#t$5&&h1/!i@$$s#f18945@i2/le#i98s#c`$%o%^n77*f(=i(*d@!e1*/n--t+/*i1/2a@@l' ...
,'D/44o#n$%7o76@@t#s&*&&9h998o()-w#t=-++h=!2i@@s#t%%^o#a$()-=n12//*8y//8-o++/n00/7e' ...
,'H@!0a-0009v$%%e#a#w%^o^&n*!@d!~*e12//*r+*/8f1-/u00l#t0/8h%^a34$n%^&k()-s[}}g;;i<>v1/8i1@@n4%g#e$@v8998e**98r7^^y))(o--=n;:e';
toFind = '\w+(\#)?'
decrypt = regexp(secretMes,toFind,'match');
unfortuantely it doesn't seem to be giving me the desitred results
Ti1fo4mato1i8t5hisfiliconfidenti2lD4n7ts9wth2stoan88on7H00eawonder8ut8anksgiv8ngev9yone
does anyone know how to achieve this?
0 commentaires
Réponses (2)
Vladimir Sovkov
le 1 Déc 2019
split(secretMes,'#')
2 commentaires
Vladimir Sovkov
le 1 Déc 2019
S=split(secretMes,'#');
S0=S{1}(S{1}>='A' & S{1}<='Z' | S{1}>='a' & S{1}<='z');
for k=2:numel(S)
S0 = strcat(S0,'_', S{k}(S{k}>='A' & S{k}<='Z' | S{k}>='a' & S{k}<='z'));
end
S0
Stephen23
le 1 Déc 2019
>> secretMes = [';,.T234h467e#i`12n390@%f&^%o1@45r1%^m]\a131@t2i*/-o+/1n#i*895n#t$5&&h1/!i@$$s#f18945@i2/le#i98s#c`$%o%^n77*f(=i(*d@!e1*/n--t+/*i1/2a@@l' ...
'D/44o#n$%7o76@@t#s&*&&9h998o()-w#t=-++h=!2i@@s#t%%^o#a$()-=n12//*8y//8-o++/n00/7e' ...
'H@!0a-0009v$%%e#a#w%^o^&n*!@d!~*e12//*r+*/8f1-/u00l#t0/8h%^a34$n%^&k()-s[}}g;;i<>v1/8i1@@n4%g#e$@v8998e**98r7^^y))(o--=n;:e'];
>> C = regexp(secretMes,'#','split');
And checking:
>> C{:}
ans = ;,.T234h467e
ans = i`12n390@%f&^%o1@45r1%^m]\a131@t2i*/-o+/1n
ans = i*895n
ans = t$5&&h1/!i@$$s
ans = f18945@i2/le
ans = i98s
ans = c`$%o%^n77*f(=i(*d@!e1*/n--t+/*i1/2a@@lD/44o
ans = n$%7o76@@t
ans = s&*&&9h998o()-w
ans = t=-++h=!2i@@s
ans = t%%^o
ans = a$()-=n12//*8y//8-o++/n00/7eH@!0a-0009v$%%e
ans = a
ans = w%^o^&n*!@d!~*e12//*r+*/8f1-/u00l
ans = t0/8h%^a34$n%^&k()-s[}}g;;i<>v1/8i1@@n4%g
ans = e$@v8998e**98r7^^y))(o--=n;:e
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!