Delete Consecutively Repeated String
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have the following text:
text = "hello","hello","hello","c","a","e","e","hello","hello"
Now I would like to do the following:
Delete every string that is "hello" and repeats itself consecutively.
Result:
text = "hello","c","a","e","e","hello"
string-manipulation
add a comment |Â
up vote
2
down vote
favorite
I have the following text:
text = "hello","hello","hello","c","a","e","e","hello","hello"
Now I would like to do the following:
Delete every string that is "hello" and repeats itself consecutively.
Result:
text = "hello","c","a","e","e","hello"
string-manipulation
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have the following text:
text = "hello","hello","hello","c","a","e","e","hello","hello"
Now I would like to do the following:
Delete every string that is "hello" and repeats itself consecutively.
Result:
text = "hello","c","a","e","e","hello"
string-manipulation
I have the following text:
text = "hello","hello","hello","c","a","e","e","hello","hello"
Now I would like to do the following:
Delete every string that is "hello" and repeats itself consecutively.
Result:
text = "hello","c","a","e","e","hello"
string-manipulation
string-manipulation
asked 42 mins ago
james
651418
651418
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
For version 11.3:
SequenceReplace[text, "hello" .. -> "hello"]
One approach for the versions older than 11.3:
Split[text] /. "hello" .. -> "hello" // Flatten
Very nice ! Thanks a lot ! :)
â james
21 mins ago
@james With pleasure :).
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
19 mins ago
add a comment |Â
up vote
2
down vote
Also
ReplaceRepeated[text, a___, Longest["hello" ..], b___ :> a, "hello", b]
"hello", "c", "a", "e", "e", "hello"
This also works. But why some codes (a___
,Longest
,b___
) in my notebook turn red?
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
15 mins ago
@ÃÂûÃÂþñýôÃÂÿÃÂÃÂõóó, i don't get that in version 9 or version 11.3.
â kglr
14 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
For version 11.3:
SequenceReplace[text, "hello" .. -> "hello"]
One approach for the versions older than 11.3:
Split[text] /. "hello" .. -> "hello" // Flatten
Very nice ! Thanks a lot ! :)
â james
21 mins ago
@james With pleasure :).
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
19 mins ago
add a comment |Â
up vote
2
down vote
accepted
For version 11.3:
SequenceReplace[text, "hello" .. -> "hello"]
One approach for the versions older than 11.3:
Split[text] /. "hello" .. -> "hello" // Flatten
Very nice ! Thanks a lot ! :)
â james
21 mins ago
@james With pleasure :).
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
19 mins ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
For version 11.3:
SequenceReplace[text, "hello" .. -> "hello"]
One approach for the versions older than 11.3:
Split[text] /. "hello" .. -> "hello" // Flatten
For version 11.3:
SequenceReplace[text, "hello" .. -> "hello"]
One approach for the versions older than 11.3:
Split[text] /. "hello" .. -> "hello" // Flatten
edited 34 mins ago
answered 39 mins ago
ÃÂûÃÂþñýôÃÂÿàÃÂõóó
2,5591826
2,5591826
Very nice ! Thanks a lot ! :)
â james
21 mins ago
@james With pleasure :).
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
19 mins ago
add a comment |Â
Very nice ! Thanks a lot ! :)
â james
21 mins ago
@james With pleasure :).
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
19 mins ago
Very nice ! Thanks a lot ! :)
â james
21 mins ago
Very nice ! Thanks a lot ! :)
â james
21 mins ago
@james With pleasure :).
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
19 mins ago
@james With pleasure :).
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
19 mins ago
add a comment |Â
up vote
2
down vote
Also
ReplaceRepeated[text, a___, Longest["hello" ..], b___ :> a, "hello", b]
"hello", "c", "a", "e", "e", "hello"
This also works. But why some codes (a___
,Longest
,b___
) in my notebook turn red?
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
15 mins ago
@ÃÂûÃÂþñýôÃÂÿÃÂÃÂõóó, i don't get that in version 9 or version 11.3.
â kglr
14 mins ago
add a comment |Â
up vote
2
down vote
Also
ReplaceRepeated[text, a___, Longest["hello" ..], b___ :> a, "hello", b]
"hello", "c", "a", "e", "e", "hello"
This also works. But why some codes (a___
,Longest
,b___
) in my notebook turn red?
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
15 mins ago
@ÃÂûÃÂþñýôÃÂÿÃÂÃÂõóó, i don't get that in version 9 or version 11.3.
â kglr
14 mins ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Also
ReplaceRepeated[text, a___, Longest["hello" ..], b___ :> a, "hello", b]
"hello", "c", "a", "e", "e", "hello"
Also
ReplaceRepeated[text, a___, Longest["hello" ..], b___ :> a, "hello", b]
"hello", "c", "a", "e", "e", "hello"
answered 18 mins ago
kglr
165k8188388
165k8188388
This also works. But why some codes (a___
,Longest
,b___
) in my notebook turn red?
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
15 mins ago
@ÃÂûÃÂþñýôÃÂÿÃÂÃÂõóó, i don't get that in version 9 or version 11.3.
â kglr
14 mins ago
add a comment |Â
This also works. But why some codes (a___
,Longest
,b___
) in my notebook turn red?
â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
15 mins ago
@ÃÂûÃÂþñýôÃÂÿÃÂÃÂõóó, i don't get that in version 9 or version 11.3.
â kglr
14 mins ago
This also works. But why some codes (
a___
, Longest
, b___
) in my notebook turn red?â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
15 mins ago
This also works. But why some codes (
a___
, Longest
, b___
) in my notebook turn red?â ÃÂûÃÂþñýôÃÂÿàÃÂõóó
15 mins ago
@ÃÂûÃÂþñýôÃÂÿÃÂÃÂõóó, i don't get that in version 9 or version 11.3.
â kglr
14 mins ago
@ÃÂûÃÂþñýôÃÂÿÃÂÃÂõóó, i don't get that in version 9 or version 11.3.
â kglr
14 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183977%2fdelete-consecutively-repeated-string%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password