Jump to content

How do I search for the $ character?


Recommended Posts

OK... so this isn't actually a PHP coding answer

But... I'm guessing the answer that works for PHP, will work for my purpose

 

Sometimes, I need to search for text containing special characters

In this instance, I'm trying to use Wingrep to search for all files that contains '$myVariable'

 

Is there a standard way of escaping the meaning of $?

 

Thanks in advance

 

 

OM

 

Link to comment
https://forums.phpfreaks.com/topic/245326-how-do-i-search-for-the-character/
Share on other sites

Since this is in the regex section I'm guessing it's related to regexes

The answer is still the backslash

\$ will escape a $, however you will also need to escape the \ in a string so it would actually be "/\\$/" for example

i tried this - didn't work

though i think i must be doing something wrong

the use of searches and regular expressions should be the same as used for php or perl (i assumed - hence i asked my question here)

thanks

It's almost certainly to do with escaping of the string. Depending on how you are running the search you probably just need more slashes. In pure regex \$ will match a dollar sign. But if you are using that in a command line tool, you likely have to escape the slash for that too. You can easily end up with strings requiring 4 slashes in order to escape them correctly to allow the correct number to make it through to the actual regex parser.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.