Regex: Matching any character (a-z and 0-9), but not $ in order to upgrade to PHP 7.2 [duplicate]

Multi tool use
Multi tool use











up vote
-1
down vote

favorite













This question already has an answer here:




  • Fix unquoted PHP array keys

    1 answer



  • How to fix associative array keys that lack single quotation marks in multiple files

    4 answers




Upgrading some really old PHP code and need to find all occurrences of array access without quotation mars (" and '). Should match [abc] but not ["abc"] or ['abc']. My regex works, but it also matches the $ character(like [$abc]), which i don't want.



Here is my full regex: [[^"'][A-Za-z0-9]+][^"'] https://regex101.com/r/uJM6DQ/1



How can I make it stop matching the $ character? Why does it match the $ character even if I never ask regex to match it?










share|improve this question













marked as duplicate by mario php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Perhaps add it to the first negated character class [[^$"'][A-Za-z0-9]+][^"']
    – The fourth bird
    Nov 11 at 12:28










  • Haha, good point, that solves the problem. Thanks! But do you know why it matches the $ in the first place?
    – Jan Greger Hemb
    Nov 11 at 12:32








  • 2




    "even if I never ask regex to match it": You do ask to match it with the negative class: [^"']. You'll agree that $ complies with that (among many other characters)
    – trincot
    Nov 11 at 12:32








  • 1




    Because you use a negated character class [^"']. The negated character class matches any character that is not in the character class.
    – The fourth bird
    Nov 11 at 12:34








  • 1




    Ah, now I understand it. Thanks for the help!
    – Jan Greger Hemb
    Nov 11 at 12:36















up vote
-1
down vote

favorite













This question already has an answer here:




  • Fix unquoted PHP array keys

    1 answer



  • How to fix associative array keys that lack single quotation marks in multiple files

    4 answers




Upgrading some really old PHP code and need to find all occurrences of array access without quotation mars (" and '). Should match [abc] but not ["abc"] or ['abc']. My regex works, but it also matches the $ character(like [$abc]), which i don't want.



Here is my full regex: [[^"'][A-Za-z0-9]+][^"'] https://regex101.com/r/uJM6DQ/1



How can I make it stop matching the $ character? Why does it match the $ character even if I never ask regex to match it?










share|improve this question













marked as duplicate by mario php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Perhaps add it to the first negated character class [[^$"'][A-Za-z0-9]+][^"']
    – The fourth bird
    Nov 11 at 12:28










  • Haha, good point, that solves the problem. Thanks! But do you know why it matches the $ in the first place?
    – Jan Greger Hemb
    Nov 11 at 12:32








  • 2




    "even if I never ask regex to match it": You do ask to match it with the negative class: [^"']. You'll agree that $ complies with that (among many other characters)
    – trincot
    Nov 11 at 12:32








  • 1




    Because you use a negated character class [^"']. The negated character class matches any character that is not in the character class.
    – The fourth bird
    Nov 11 at 12:34








  • 1




    Ah, now I understand it. Thanks for the help!
    – Jan Greger Hemb
    Nov 11 at 12:36













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












This question already has an answer here:




  • Fix unquoted PHP array keys

    1 answer



  • How to fix associative array keys that lack single quotation marks in multiple files

    4 answers




Upgrading some really old PHP code and need to find all occurrences of array access without quotation mars (" and '). Should match [abc] but not ["abc"] or ['abc']. My regex works, but it also matches the $ character(like [$abc]), which i don't want.



Here is my full regex: [[^"'][A-Za-z0-9]+][^"'] https://regex101.com/r/uJM6DQ/1



How can I make it stop matching the $ character? Why does it match the $ character even if I never ask regex to match it?










share|improve this question














This question already has an answer here:




  • Fix unquoted PHP array keys

    1 answer



  • How to fix associative array keys that lack single quotation marks in multiple files

    4 answers




Upgrading some really old PHP code and need to find all occurrences of array access without quotation mars (" and '). Should match [abc] but not ["abc"] or ['abc']. My regex works, but it also matches the $ character(like [$abc]), which i don't want.



Here is my full regex: [[^"'][A-Za-z0-9]+][^"'] https://regex101.com/r/uJM6DQ/1



How can I make it stop matching the $ character? Why does it match the $ character even if I never ask regex to match it?





This question already has an answer here:




  • Fix unquoted PHP array keys

    1 answer



  • How to fix associative array keys that lack single quotation marks in multiple files

    4 answers








php regex






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 12:27









Jan Greger Hemb

156




156




marked as duplicate by mario php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by mario php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    Perhaps add it to the first negated character class [[^$"'][A-Za-z0-9]+][^"']
    – The fourth bird
    Nov 11 at 12:28










  • Haha, good point, that solves the problem. Thanks! But do you know why it matches the $ in the first place?
    – Jan Greger Hemb
    Nov 11 at 12:32








  • 2




    "even if I never ask regex to match it": You do ask to match it with the negative class: [^"']. You'll agree that $ complies with that (among many other characters)
    – trincot
    Nov 11 at 12:32








  • 1




    Because you use a negated character class [^"']. The negated character class matches any character that is not in the character class.
    – The fourth bird
    Nov 11 at 12:34








  • 1




    Ah, now I understand it. Thanks for the help!
    – Jan Greger Hemb
    Nov 11 at 12:36














  • 1




    Perhaps add it to the first negated character class [[^$"'][A-Za-z0-9]+][^"']
    – The fourth bird
    Nov 11 at 12:28










  • Haha, good point, that solves the problem. Thanks! But do you know why it matches the $ in the first place?
    – Jan Greger Hemb
    Nov 11 at 12:32








  • 2




    "even if I never ask regex to match it": You do ask to match it with the negative class: [^"']. You'll agree that $ complies with that (among many other characters)
    – trincot
    Nov 11 at 12:32








  • 1




    Because you use a negated character class [^"']. The negated character class matches any character that is not in the character class.
    – The fourth bird
    Nov 11 at 12:34








  • 1




    Ah, now I understand it. Thanks for the help!
    – Jan Greger Hemb
    Nov 11 at 12:36








1




1




Perhaps add it to the first negated character class [[^$"'][A-Za-z0-9]+][^"']
– The fourth bird
Nov 11 at 12:28




Perhaps add it to the first negated character class [[^$"'][A-Za-z0-9]+][^"']
– The fourth bird
Nov 11 at 12:28












Haha, good point, that solves the problem. Thanks! But do you know why it matches the $ in the first place?
– Jan Greger Hemb
Nov 11 at 12:32






Haha, good point, that solves the problem. Thanks! But do you know why it matches the $ in the first place?
– Jan Greger Hemb
Nov 11 at 12:32






2




2




"even if I never ask regex to match it": You do ask to match it with the negative class: [^"']. You'll agree that $ complies with that (among many other characters)
– trincot
Nov 11 at 12:32






"even if I never ask regex to match it": You do ask to match it with the negative class: [^"']. You'll agree that $ complies with that (among many other characters)
– trincot
Nov 11 at 12:32






1




1




Because you use a negated character class [^"']. The negated character class matches any character that is not in the character class.
– The fourth bird
Nov 11 at 12:34






Because you use a negated character class [^"']. The negated character class matches any character that is not in the character class.
– The fourth bird
Nov 11 at 12:34






1




1




Ah, now I understand it. Thanks for the help!
– Jan Greger Hemb
Nov 11 at 12:36




Ah, now I understand it. Thanks for the help!
– Jan Greger Hemb
Nov 11 at 12:36

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

zwzt9qe 56rMWxlrlDsUdGJ3f7u 7jcOzxMztzyapPs72Sv JLIOs9qVLMu3hJag8pPTDxotFd,Ut,7Ii29v6X
eq7BCkI,iJk6rjKOOPj FjgYRONVboz3fSJawcc,u0VEB

Popular posts from this blog

Bressuire

Vorschmack

Xamarin.iOS Cant Deploy on Iphone