Search and replace using a custom utility
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I want to run a utility for replace values matching a regular expression. This means for every match of a regular expression, call the utility with the characters comprising the match. The output of the utility replaces the original characters.
For illustration purposes using factor
:
$ factor 230
230: 2 5 23
So using this utility, I want to pick out the integers, call factor
with the integer, and replace the original integer with the output of factor
.
This is what I would expect on a sample input:
$ [code] <<< "Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes."
Given the numbers with factors: 27: 3 3 3, 13: 13, 230: 2 5 23, and 19: 19, it is evident which are primes.
I thought this might work, but it looks like it's trying to interpret the input directly. Using sed (GNU sed) 4.2.2
.
$ sed -E 's/([0-9]+)/factor 1/ge' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
sh: 1: Given: not found
Obviously I'm not understanding what the e
flag does. Removing the e
shows that the regular expression is correctly pulling out the integers and passing them as 1
.
I tried doing this in awk
:
$ awk 'r = gensub(/([0-9]+)/, system("factor \1"), "g"); print r' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
1:
Given the numbers with factors: 0, 0, 0, and 0, it is evident which are primes.
I'm not sure where the 1:
comes from, but it's apparent that it's printing just the return code from system
. There doesn't appear to be a way to capture the standard output from a command in awk
.
Is what I'm asking for possible using the core utilities?
awk sed perl string
add a comment |Â
up vote
1
down vote
favorite
I want to run a utility for replace values matching a regular expression. This means for every match of a regular expression, call the utility with the characters comprising the match. The output of the utility replaces the original characters.
For illustration purposes using factor
:
$ factor 230
230: 2 5 23
So using this utility, I want to pick out the integers, call factor
with the integer, and replace the original integer with the output of factor
.
This is what I would expect on a sample input:
$ [code] <<< "Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes."
Given the numbers with factors: 27: 3 3 3, 13: 13, 230: 2 5 23, and 19: 19, it is evident which are primes.
I thought this might work, but it looks like it's trying to interpret the input directly. Using sed (GNU sed) 4.2.2
.
$ sed -E 's/([0-9]+)/factor 1/ge' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
sh: 1: Given: not found
Obviously I'm not understanding what the e
flag does. Removing the e
shows that the regular expression is correctly pulling out the integers and passing them as 1
.
I tried doing this in awk
:
$ awk 'r = gensub(/([0-9]+)/, system("factor \1"), "g"); print r' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
1:
Given the numbers with factors: 0, 0, 0, and 0, it is evident which are primes.
I'm not sure where the 1:
comes from, but it's apparent that it's printing just the return code from system
. There doesn't appear to be a way to capture the standard output from a command in awk
.
Is what I'm asking for possible using the core utilities?
awk sed perl string
elaborate your for every match in the input, because for now you are reversing all words. Post a testable input which would contain matched and non-matched items
â RomanPerekhrest
Jul 18 at 13:48
@RomanPerekhrest â For every match of a regular expression, call a custom utility with the characters comprising the match. The output of the custom utility replaces the original characters.
â Yimin Rong
Jul 18 at 13:52
again, Post a testable input which would contain matched and non-matched items. Also, elaborate if a regex pattern could cover a part of the word or the whole word only
â RomanPerekhrest
Jul 18 at 13:57
@RomanPerekhrest - Replacedreverse
withfactor
. People are fixated on this red herring.
â Yimin Rong
Jul 18 at 14:39
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to run a utility for replace values matching a regular expression. This means for every match of a regular expression, call the utility with the characters comprising the match. The output of the utility replaces the original characters.
For illustration purposes using factor
:
$ factor 230
230: 2 5 23
So using this utility, I want to pick out the integers, call factor
with the integer, and replace the original integer with the output of factor
.
This is what I would expect on a sample input:
$ [code] <<< "Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes."
Given the numbers with factors: 27: 3 3 3, 13: 13, 230: 2 5 23, and 19: 19, it is evident which are primes.
I thought this might work, but it looks like it's trying to interpret the input directly. Using sed (GNU sed) 4.2.2
.
$ sed -E 's/([0-9]+)/factor 1/ge' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
sh: 1: Given: not found
Obviously I'm not understanding what the e
flag does. Removing the e
shows that the regular expression is correctly pulling out the integers and passing them as 1
.
I tried doing this in awk
:
$ awk 'r = gensub(/([0-9]+)/, system("factor \1"), "g"); print r' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
1:
Given the numbers with factors: 0, 0, 0, and 0, it is evident which are primes.
I'm not sure where the 1:
comes from, but it's apparent that it's printing just the return code from system
. There doesn't appear to be a way to capture the standard output from a command in awk
.
Is what I'm asking for possible using the core utilities?
awk sed perl string
I want to run a utility for replace values matching a regular expression. This means for every match of a regular expression, call the utility with the characters comprising the match. The output of the utility replaces the original characters.
For illustration purposes using factor
:
$ factor 230
230: 2 5 23
So using this utility, I want to pick out the integers, call factor
with the integer, and replace the original integer with the output of factor
.
This is what I would expect on a sample input:
$ [code] <<< "Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes."
Given the numbers with factors: 27: 3 3 3, 13: 13, 230: 2 5 23, and 19: 19, it is evident which are primes.
I thought this might work, but it looks like it's trying to interpret the input directly. Using sed (GNU sed) 4.2.2
.
$ sed -E 's/([0-9]+)/factor 1/ge' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
sh: 1: Given: not found
Obviously I'm not understanding what the e
flag does. Removing the e
shows that the regular expression is correctly pulling out the integers and passing them as 1
.
I tried doing this in awk
:
$ awk 'r = gensub(/([0-9]+)/, system("factor \1"), "g"); print r' <<< 'Given the numbers with factors: 27, 13, 230, and 19, it is evident which are primes.'
1:
Given the numbers with factors: 0, 0, 0, and 0, it is evident which are primes.
I'm not sure where the 1:
comes from, but it's apparent that it's printing just the return code from system
. There doesn't appear to be a way to capture the standard output from a command in awk
.
Is what I'm asking for possible using the core utilities?
awk sed perl string
edited Jul 18 at 15:53
asked Jul 18 at 13:16
Yimin Rong
2231415
2231415
elaborate your for every match in the input, because for now you are reversing all words. Post a testable input which would contain matched and non-matched items
â RomanPerekhrest
Jul 18 at 13:48
@RomanPerekhrest â For every match of a regular expression, call a custom utility with the characters comprising the match. The output of the custom utility replaces the original characters.
â Yimin Rong
Jul 18 at 13:52
again, Post a testable input which would contain matched and non-matched items. Also, elaborate if a regex pattern could cover a part of the word or the whole word only
â RomanPerekhrest
Jul 18 at 13:57
@RomanPerekhrest - Replacedreverse
withfactor
. People are fixated on this red herring.
â Yimin Rong
Jul 18 at 14:39
add a comment |Â
elaborate your for every match in the input, because for now you are reversing all words. Post a testable input which would contain matched and non-matched items
â RomanPerekhrest
Jul 18 at 13:48
@RomanPerekhrest â For every match of a regular expression, call a custom utility with the characters comprising the match. The output of the custom utility replaces the original characters.
â Yimin Rong
Jul 18 at 13:52
again, Post a testable input which would contain matched and non-matched items. Also, elaborate if a regex pattern could cover a part of the word or the whole word only
â RomanPerekhrest
Jul 18 at 13:57
@RomanPerekhrest - Replacedreverse
withfactor
. People are fixated on this red herring.
â Yimin Rong
Jul 18 at 14:39
elaborate your for every match in the input, because for now you are reversing all words. Post a testable input which would contain matched and non-matched items
â RomanPerekhrest
Jul 18 at 13:48
elaborate your for every match in the input, because for now you are reversing all words. Post a testable input which would contain matched and non-matched items
â RomanPerekhrest
Jul 18 at 13:48
@RomanPerekhrest â For every match of a regular expression, call a custom utility with the characters comprising the match. The output of the custom utility replaces the original characters.
â Yimin Rong
Jul 18 at 13:52
@RomanPerekhrest â For every match of a regular expression, call a custom utility with the characters comprising the match. The output of the custom utility replaces the original characters.
â Yimin Rong
Jul 18 at 13:52
again, Post a testable input which would contain matched and non-matched items. Also, elaborate if a regex pattern could cover a part of the word or the whole word only
â RomanPerekhrest
Jul 18 at 13:57
again, Post a testable input which would contain matched and non-matched items. Also, elaborate if a regex pattern could cover a part of the word or the whole word only
â RomanPerekhrest
Jul 18 at 13:57
@RomanPerekhrest - Replaced
reverse
with factor
. People are fixated on this red herring.â Yimin Rong
Jul 18 at 14:39
@RomanPerekhrest - Replaced
reverse
with factor
. People are fixated on this red herring.â Yimin Rong
Jul 18 at 14:39
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
1
down vote
Possible in Perl. Using split, map, scalar, lc, reverse, ucfirst, join. A bit more complex than I originally thought because of the commas and context sensitivity of matching.
#!/usr/bin/perl
use warnings;
use strict;
sub rev
my ($string) = @_;
my @words = split /(W+)/, $string;
my @caps = map scalar(/^[[:upper:]]/), @words;
$_ = /w/ ? lc reverse : $_ for @words;
shift @caps and $_ = ucfirst for @words;
return join "", @words
use Test::More tests => 1;
my $r = rev('Hello, my name is Yimin Rong.');
is $r, 'Olleh, ym eman si Nimiy Gnor.';
Thanks, but I usedreverse
just as an illustration. The actual utility I need to use is much more complex. Imaginereverse
as a black box not easily duplicated in a scripting language.
â Yimin Rong
Jul 18 at 13:35
The trick is to writereverse
in Perl, too ;-)
â choroba
Jul 18 at 13:42
Trust me, what I'm using isn't easy in perl, think about a factoring utility using the general number field sieve.
â Yimin Rong
Jul 18 at 13:46
@YiminRong: If it's easy in shell, it must be easy in Perl, too.
â choroba
Jul 18 at 14:11
Rewrote to illustrate withfactor
. Good luck writing that inperl
!
â Yimin Rong
Jul 18 at 15:06
 |Â
show 1 more comment
up vote
0
down vote
Try the below awk solution:
echo "Hello" | awk ' for ( i=length($0);i>0;i-- ) if (i == length($0) ) printf "%s",toupper(substr($0,i,1)) else printf "%s",tolower(substr($0,i,1)) printf "n" '
Take each letter of the word character by character stating from the last. If it is the last character, convert to upper case and print otherwise print lower case.
add a comment |Â
up vote
0
down vote
Run the following :
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
The reason why your sed command is not working is because sed will execute the entire pattern space unlike Perl which is aligned with how you were thinking and executes just as much as is on the rhs of the s/// command and replaces tonly that much with the command output.
And that's precisely why if you notice sed was cribbing abt "Given:" utility not found. Given was the beginning of your pattern space. HTH
add a comment |Â
up vote
-1
down vote
Run the following:
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
Care to explain how this works?
â Kusalananda
Jul 20 at 19:08
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Possible in Perl. Using split, map, scalar, lc, reverse, ucfirst, join. A bit more complex than I originally thought because of the commas and context sensitivity of matching.
#!/usr/bin/perl
use warnings;
use strict;
sub rev
my ($string) = @_;
my @words = split /(W+)/, $string;
my @caps = map scalar(/^[[:upper:]]/), @words;
$_ = /w/ ? lc reverse : $_ for @words;
shift @caps and $_ = ucfirst for @words;
return join "", @words
use Test::More tests => 1;
my $r = rev('Hello, my name is Yimin Rong.');
is $r, 'Olleh, ym eman si Nimiy Gnor.';
Thanks, but I usedreverse
just as an illustration. The actual utility I need to use is much more complex. Imaginereverse
as a black box not easily duplicated in a scripting language.
â Yimin Rong
Jul 18 at 13:35
The trick is to writereverse
in Perl, too ;-)
â choroba
Jul 18 at 13:42
Trust me, what I'm using isn't easy in perl, think about a factoring utility using the general number field sieve.
â Yimin Rong
Jul 18 at 13:46
@YiminRong: If it's easy in shell, it must be easy in Perl, too.
â choroba
Jul 18 at 14:11
Rewrote to illustrate withfactor
. Good luck writing that inperl
!
â Yimin Rong
Jul 18 at 15:06
 |Â
show 1 more comment
up vote
1
down vote
Possible in Perl. Using split, map, scalar, lc, reverse, ucfirst, join. A bit more complex than I originally thought because of the commas and context sensitivity of matching.
#!/usr/bin/perl
use warnings;
use strict;
sub rev
my ($string) = @_;
my @words = split /(W+)/, $string;
my @caps = map scalar(/^[[:upper:]]/), @words;
$_ = /w/ ? lc reverse : $_ for @words;
shift @caps and $_ = ucfirst for @words;
return join "", @words
use Test::More tests => 1;
my $r = rev('Hello, my name is Yimin Rong.');
is $r, 'Olleh, ym eman si Nimiy Gnor.';
Thanks, but I usedreverse
just as an illustration. The actual utility I need to use is much more complex. Imaginereverse
as a black box not easily duplicated in a scripting language.
â Yimin Rong
Jul 18 at 13:35
The trick is to writereverse
in Perl, too ;-)
â choroba
Jul 18 at 13:42
Trust me, what I'm using isn't easy in perl, think about a factoring utility using the general number field sieve.
â Yimin Rong
Jul 18 at 13:46
@YiminRong: If it's easy in shell, it must be easy in Perl, too.
â choroba
Jul 18 at 14:11
Rewrote to illustrate withfactor
. Good luck writing that inperl
!
â Yimin Rong
Jul 18 at 15:06
 |Â
show 1 more comment
up vote
1
down vote
up vote
1
down vote
Possible in Perl. Using split, map, scalar, lc, reverse, ucfirst, join. A bit more complex than I originally thought because of the commas and context sensitivity of matching.
#!/usr/bin/perl
use warnings;
use strict;
sub rev
my ($string) = @_;
my @words = split /(W+)/, $string;
my @caps = map scalar(/^[[:upper:]]/), @words;
$_ = /w/ ? lc reverse : $_ for @words;
shift @caps and $_ = ucfirst for @words;
return join "", @words
use Test::More tests => 1;
my $r = rev('Hello, my name is Yimin Rong.');
is $r, 'Olleh, ym eman si Nimiy Gnor.';
Possible in Perl. Using split, map, scalar, lc, reverse, ucfirst, join. A bit more complex than I originally thought because of the commas and context sensitivity of matching.
#!/usr/bin/perl
use warnings;
use strict;
sub rev
my ($string) = @_;
my @words = split /(W+)/, $string;
my @caps = map scalar(/^[[:upper:]]/), @words;
$_ = /w/ ? lc reverse : $_ for @words;
shift @caps and $_ = ucfirst for @words;
return join "", @words
use Test::More tests => 1;
my $r = rev('Hello, my name is Yimin Rong.');
is $r, 'Olleh, ym eman si Nimiy Gnor.';
answered Jul 18 at 13:31
choroba
24.1k33967
24.1k33967
Thanks, but I usedreverse
just as an illustration. The actual utility I need to use is much more complex. Imaginereverse
as a black box not easily duplicated in a scripting language.
â Yimin Rong
Jul 18 at 13:35
The trick is to writereverse
in Perl, too ;-)
â choroba
Jul 18 at 13:42
Trust me, what I'm using isn't easy in perl, think about a factoring utility using the general number field sieve.
â Yimin Rong
Jul 18 at 13:46
@YiminRong: If it's easy in shell, it must be easy in Perl, too.
â choroba
Jul 18 at 14:11
Rewrote to illustrate withfactor
. Good luck writing that inperl
!
â Yimin Rong
Jul 18 at 15:06
 |Â
show 1 more comment
Thanks, but I usedreverse
just as an illustration. The actual utility I need to use is much more complex. Imaginereverse
as a black box not easily duplicated in a scripting language.
â Yimin Rong
Jul 18 at 13:35
The trick is to writereverse
in Perl, too ;-)
â choroba
Jul 18 at 13:42
Trust me, what I'm using isn't easy in perl, think about a factoring utility using the general number field sieve.
â Yimin Rong
Jul 18 at 13:46
@YiminRong: If it's easy in shell, it must be easy in Perl, too.
â choroba
Jul 18 at 14:11
Rewrote to illustrate withfactor
. Good luck writing that inperl
!
â Yimin Rong
Jul 18 at 15:06
Thanks, but I used
reverse
just as an illustration. The actual utility I need to use is much more complex. Imagine reverse
as a black box not easily duplicated in a scripting language.â Yimin Rong
Jul 18 at 13:35
Thanks, but I used
reverse
just as an illustration. The actual utility I need to use is much more complex. Imagine reverse
as a black box not easily duplicated in a scripting language.â Yimin Rong
Jul 18 at 13:35
The trick is to write
reverse
in Perl, too ;-)â choroba
Jul 18 at 13:42
The trick is to write
reverse
in Perl, too ;-)â choroba
Jul 18 at 13:42
Trust me, what I'm using isn't easy in perl, think about a factoring utility using the general number field sieve.
â Yimin Rong
Jul 18 at 13:46
Trust me, what I'm using isn't easy in perl, think about a factoring utility using the general number field sieve.
â Yimin Rong
Jul 18 at 13:46
@YiminRong: If it's easy in shell, it must be easy in Perl, too.
â choroba
Jul 18 at 14:11
@YiminRong: If it's easy in shell, it must be easy in Perl, too.
â choroba
Jul 18 at 14:11
Rewrote to illustrate with
factor
. Good luck writing that in perl
!â Yimin Rong
Jul 18 at 15:06
Rewrote to illustrate with
factor
. Good luck writing that in perl
!â Yimin Rong
Jul 18 at 15:06
 |Â
show 1 more comment
up vote
0
down vote
Try the below awk solution:
echo "Hello" | awk ' for ( i=length($0);i>0;i-- ) if (i == length($0) ) printf "%s",toupper(substr($0,i,1)) else printf "%s",tolower(substr($0,i,1)) printf "n" '
Take each letter of the word character by character stating from the last. If it is the last character, convert to upper case and print otherwise print lower case.
add a comment |Â
up vote
0
down vote
Try the below awk solution:
echo "Hello" | awk ' for ( i=length($0);i>0;i-- ) if (i == length($0) ) printf "%s",toupper(substr($0,i,1)) else printf "%s",tolower(substr($0,i,1)) printf "n" '
Take each letter of the word character by character stating from the last. If it is the last character, convert to upper case and print otherwise print lower case.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Try the below awk solution:
echo "Hello" | awk ' for ( i=length($0);i>0;i-- ) if (i == length($0) ) printf "%s",toupper(substr($0,i,1)) else printf "%s",tolower(substr($0,i,1)) printf "n" '
Take each letter of the word character by character stating from the last. If it is the last character, convert to upper case and print otherwise print lower case.
Try the below awk solution:
echo "Hello" | awk ' for ( i=length($0);i>0;i-- ) if (i == length($0) ) printf "%s",toupper(substr($0,i,1)) else printf "%s",tolower(substr($0,i,1)) printf "n" '
Take each letter of the word character by character stating from the last. If it is the last character, convert to upper case and print otherwise print lower case.
answered Jul 18 at 13:57
Raman Sailopal
1,16317
1,16317
add a comment |Â
add a comment |Â
up vote
0
down vote
Run the following :
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
The reason why your sed command is not working is because sed will execute the entire pattern space unlike Perl which is aligned with how you were thinking and executes just as much as is on the rhs of the s/// command and replaces tonly that much with the command output.
And that's precisely why if you notice sed was cribbing abt "Given:" utility not found. Given was the beginning of your pattern space. HTH
add a comment |Â
up vote
0
down vote
Run the following :
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
The reason why your sed command is not working is because sed will execute the entire pattern space unlike Perl which is aligned with how you were thinking and executes just as much as is on the rhs of the s/// command and replaces tonly that much with the command output.
And that's precisely why if you notice sed was cribbing abt "Given:" utility not found. Given was the beginning of your pattern space. HTH
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Run the following :
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
The reason why your sed command is not working is because sed will execute the entire pattern space unlike Perl which is aligned with how you were thinking and executes just as much as is on the rhs of the s/// command and replaces tonly that much with the command output.
And that's precisely why if you notice sed was cribbing abt "Given:" utility not found. Given was the beginning of your pattern space. HTH
Run the following :
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
The reason why your sed command is not working is because sed will execute the entire pattern space unlike Perl which is aligned with how you were thinking and executes just as much as is on the rhs of the s/// command and replaces tonly that much with the command output.
And that's precisely why if you notice sed was cribbing abt "Given:" utility not found. Given was the beginning of your pattern space. HTH
edited Jul 20 at 18:48
answered Jul 20 at 18:09
Rakesh Sharma
11013
11013
add a comment |Â
add a comment |Â
up vote
-1
down vote
Run the following:
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
Care to explain how this works?
â Kusalananda
Jul 20 at 19:08
add a comment |Â
up vote
-1
down vote
Run the following:
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
Care to explain how this works?
â Kusalananda
Jul 20 at 19:08
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
Run the following:
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
Run the following:
perl -pe 's/(d+)/qx(factor $1) =~ s|n||r/ge' input-file.txt
edited Jul 20 at 19:43
Jeff Schaller
30.8k846104
30.8k846104
answered Jul 20 at 18:07
Rakesh Sharma
11013
11013
Care to explain how this works?
â Kusalananda
Jul 20 at 19:08
add a comment |Â
Care to explain how this works?
â Kusalananda
Jul 20 at 19:08
Care to explain how this works?
â Kusalananda
Jul 20 at 19:08
Care to explain how this works?
â Kusalananda
Jul 20 at 19:08
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%2funix.stackexchange.com%2fquestions%2f456991%2fsearch-and-replace-using-a-custom-utility%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
elaborate your for every match in the input, because for now you are reversing all words. Post a testable input which would contain matched and non-matched items
â RomanPerekhrest
Jul 18 at 13:48
@RomanPerekhrest â For every match of a regular expression, call a custom utility with the characters comprising the match. The output of the custom utility replaces the original characters.
â Yimin Rong
Jul 18 at 13:52
again, Post a testable input which would contain matched and non-matched items. Also, elaborate if a regex pattern could cover a part of the word or the whole word only
â RomanPerekhrest
Jul 18 at 13:57
@RomanPerekhrest - Replaced
reverse
withfactor
. People are fixated on this red herring.â Yimin Rong
Jul 18 at 14:39