append brackets to all constants beginning with L:: where it not exist on endAdd space after 8 characters then add space after every 4 charactersCleaning PHP exploits from infected files using sedDelete multiple lines in a fileProblems with regex in grepsubstitute from beginning of line with 1 of multiple patterns to the end of another line with 2nd patternUse sed and sed alone to do a substitution on a line starting with a specific string only if !existHow to copy strings from middle of lines (between strings) to the end of linesBash variables in sed including an end of line conditionsed: couldn't write n items to stdout: Broken pipe. What are these errors?Find and replace inside string based on pattern and exception cases
Detention in 1997
Do UK voters know if their MP will be the Speaker of the House?
Avoiding direct proof while writing proof by induction
What is the most common color to indicate the input-field is disabled?
Alternative to sending password over mail?
CAST throwing error when run in stored procedure but not when run as raw query
Personal Teleportation: From Rags to Riches
Assassin's bullet with mercury
What exploit Are these user agents trying to use?
Why is this clock signal connected to a capacitor to gnd?
Am I breaking OOP practice with this architecture?
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
Is it logically or scientifically possible to artificially send energy to the body?
Avoiding the "not like other girls" trope?
Why was the shrinking from 8″ made only to 5.25″ and not smaller (4″ or less)?
How can saying a song's name be a copyright violation?
One verb to replace 'be a member of' a club
Why can't we play rap on piano?
What does “the session was packed” mean in this context?
Are there any examples of a variable being normally distributed that is *not* due to the Central Limit Theorem?
What mechanic is there to disable a threat instead of killing it?
How writing a dominant 7 sus4 chord in RNA ( Vsus7 chord in the 1st inversion)
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
Can compressed videos be decoded back to their uncompresed original format?
append brackets to all constants beginning with L:: where it not exist on end
Add space after 8 characters then add space after every 4 charactersCleaning PHP exploits from infected files using sedDelete multiple lines in a fileProblems with regex in grepsubstitute from beginning of line with 1 of multiple patterns to the end of another line with 2nd patternUse sed and sed alone to do a substitution on a line starting with a specific string only if !existHow to copy strings from middle of lines (between strings) to the end of linesBash variables in sed including an end of line conditionsed: couldn't write n items to stdout: Broken pipe. What are these errors?Find and replace inside string based on pattern and exception cases
I have many PHP Files where I need to add on end "()" to every constant beginning with "L::" which don't have on end "(". It should by applied to all *.php including subfolders) :
L::WHAT_EVER
<?=L::WHAT_EVER?>
should become:
L::WHAT_EVER()
<?=L::WHAT_EVER()?>
but not touch any of them:
L::WHAT_EVER()
L::WHAT_EVER('aaa')
L::WHAT_EVER($a, $b)
Is there any sed regex command that I could apply to reach this Goal?
shell sed regular-expression
New contributor
add a comment |
I have many PHP Files where I need to add on end "()" to every constant beginning with "L::" which don't have on end "(". It should by applied to all *.php including subfolders) :
L::WHAT_EVER
<?=L::WHAT_EVER?>
should become:
L::WHAT_EVER()
<?=L::WHAT_EVER()?>
but not touch any of them:
L::WHAT_EVER()
L::WHAT_EVER('aaa')
L::WHAT_EVER($a, $b)
Is there any sed regex command that I could apply to reach this Goal?
shell sed regular-expression
New contributor
1
yes there is ...
– ctac_
2 days ago
add a comment |
I have many PHP Files where I need to add on end "()" to every constant beginning with "L::" which don't have on end "(". It should by applied to all *.php including subfolders) :
L::WHAT_EVER
<?=L::WHAT_EVER?>
should become:
L::WHAT_EVER()
<?=L::WHAT_EVER()?>
but not touch any of them:
L::WHAT_EVER()
L::WHAT_EVER('aaa')
L::WHAT_EVER($a, $b)
Is there any sed regex command that I could apply to reach this Goal?
shell sed regular-expression
New contributor
I have many PHP Files where I need to add on end "()" to every constant beginning with "L::" which don't have on end "(". It should by applied to all *.php including subfolders) :
L::WHAT_EVER
<?=L::WHAT_EVER?>
should become:
L::WHAT_EVER()
<?=L::WHAT_EVER()?>
but not touch any of them:
L::WHAT_EVER()
L::WHAT_EVER('aaa')
L::WHAT_EVER($a, $b)
Is there any sed regex command that I could apply to reach this Goal?
shell sed regular-expression
shell sed regular-expression
New contributor
New contributor
New contributor
asked 2 days ago
nenad007nenad007
82
82
New contributor
New contributor
1
yes there is ...
– ctac_
2 days ago
add a comment |
1
yes there is ...
– ctac_
2 days ago
1
1
yes there is ...
– ctac_
2 days ago
yes there is ...
– ctac_
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
It's easier with perl
:
perl -pi -e 's/bL::w++K(?!()/()/g' ./*.php
bL::
:L::
following a word boundary (to avoid replacingNIL::Foo
ones).w
: any word character (ASCII letters, numbers or underscore)++
: one or more (of thew
s), but don't backtrackK
: set the start of the matched portion (so just after that word)(?!...)
: negative look ahead assertion. So here only matches if what follows is not a(
.
add a comment |
Perl and the better regex engine is easier as it has lookaround feature, for GNU sed testing:
sed -E 's/(w+::w+)([^(].+)?/1()2/' ./*.php
solving recursive glob process:
find . -iname '*.php' -exec sed -E 's/(w+::w+)([^(].+)?/1()2/' '' +
for its real editing, add -i option,
find . -iname '*.php' -exec sed -i -E 's/(w+::w+)([^(].+)?/1()2/' '' +
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
nenad007 is a new contributor. Be nice, and check out our Code of Conduct.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509903%2fappend-brackets-to-all-constants-beginning-with-l-where-it-not-exist-on-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's easier with perl
:
perl -pi -e 's/bL::w++K(?!()/()/g' ./*.php
bL::
:L::
following a word boundary (to avoid replacingNIL::Foo
ones).w
: any word character (ASCII letters, numbers or underscore)++
: one or more (of thew
s), but don't backtrackK
: set the start of the matched portion (so just after that word)(?!...)
: negative look ahead assertion. So here only matches if what follows is not a(
.
add a comment |
It's easier with perl
:
perl -pi -e 's/bL::w++K(?!()/()/g' ./*.php
bL::
:L::
following a word boundary (to avoid replacingNIL::Foo
ones).w
: any word character (ASCII letters, numbers or underscore)++
: one or more (of thew
s), but don't backtrackK
: set the start of the matched portion (so just after that word)(?!...)
: negative look ahead assertion. So here only matches if what follows is not a(
.
add a comment |
It's easier with perl
:
perl -pi -e 's/bL::w++K(?!()/()/g' ./*.php
bL::
:L::
following a word boundary (to avoid replacingNIL::Foo
ones).w
: any word character (ASCII letters, numbers or underscore)++
: one or more (of thew
s), but don't backtrackK
: set the start of the matched portion (so just after that word)(?!...)
: negative look ahead assertion. So here only matches if what follows is not a(
.
It's easier with perl
:
perl -pi -e 's/bL::w++K(?!()/()/g' ./*.php
bL::
:L::
following a word boundary (to avoid replacingNIL::Foo
ones).w
: any word character (ASCII letters, numbers or underscore)++
: one or more (of thew
s), but don't backtrackK
: set the start of the matched portion (so just after that word)(?!...)
: negative look ahead assertion. So here only matches if what follows is not a(
.
edited 2 days ago
answered 2 days ago
Stéphane ChazelasStéphane Chazelas
312k57592948
312k57592948
add a comment |
add a comment |
Perl and the better regex engine is easier as it has lookaround feature, for GNU sed testing:
sed -E 's/(w+::w+)([^(].+)?/1()2/' ./*.php
solving recursive glob process:
find . -iname '*.php' -exec sed -E 's/(w+::w+)([^(].+)?/1()2/' '' +
for its real editing, add -i option,
find . -iname '*.php' -exec sed -i -E 's/(w+::w+)([^(].+)?/1()2/' '' +
add a comment |
Perl and the better regex engine is easier as it has lookaround feature, for GNU sed testing:
sed -E 's/(w+::w+)([^(].+)?/1()2/' ./*.php
solving recursive glob process:
find . -iname '*.php' -exec sed -E 's/(w+::w+)([^(].+)?/1()2/' '' +
for its real editing, add -i option,
find . -iname '*.php' -exec sed -i -E 's/(w+::w+)([^(].+)?/1()2/' '' +
add a comment |
Perl and the better regex engine is easier as it has lookaround feature, for GNU sed testing:
sed -E 's/(w+::w+)([^(].+)?/1()2/' ./*.php
solving recursive glob process:
find . -iname '*.php' -exec sed -E 's/(w+::w+)([^(].+)?/1()2/' '' +
for its real editing, add -i option,
find . -iname '*.php' -exec sed -i -E 's/(w+::w+)([^(].+)?/1()2/' '' +
Perl and the better regex engine is easier as it has lookaround feature, for GNU sed testing:
sed -E 's/(w+::w+)([^(].+)?/1()2/' ./*.php
solving recursive glob process:
find . -iname '*.php' -exec sed -E 's/(w+::w+)([^(].+)?/1()2/' '' +
for its real editing, add -i option,
find . -iname '*.php' -exec sed -i -E 's/(w+::w+)([^(].+)?/1()2/' '' +
edited 14 hours ago
Stéphane Chazelas
312k57592948
312k57592948
answered 15 hours ago
abdanabdan
374
374
add a comment |
add a comment |
nenad007 is a new contributor. Be nice, and check out our Code of Conduct.
nenad007 is a new contributor. Be nice, and check out our Code of Conduct.
nenad007 is a new contributor. Be nice, and check out our Code of Conduct.
nenad007 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509903%2fappend-brackets-to-all-constants-beginning-with-l-where-it-not-exist-on-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
yes there is ...
– ctac_
2 days ago