---
title: "How we list which characters we DON'T want ?How to use backslash character"  
description: "How we list which characters we DON'T want ?How to use backslash character"  
author: "Andrew Deniel"  
published: 2013-06-08  
updated: 2020-09-15  
canonical: https://www.mindstick.com/interview/1763/how-we-list-which-characters-we-don-t-want-how-to-use-backslash-character  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# How we list which characters we DON'T want ?How to use backslash character

We can list which characters we DON'T want so just use a '^' as the first symbol in a bracket expression(i.e., "%[^a-zA-Z]%" matches a string with a character that is not a letter between two percent signs)."^[a-zA-Z]": a string that starts with a letter;"[0-9]%": a string that has a single digit before a percent sign;",[a-zA-Z0-9]$": a string that ends in a comma followed by an alphanumeric character. \
In order to be taken literally, you must escape the characters "^.[$()|*+?{\" with a backslash ('\'), as they have special meaning. On top of that, you must escape the backslash character itself in PHP3 strings, so, for instance, the regular expression "(\$|¥)[0-9]+" would have the function call: ereg("(\\$|¥)[0-9]+", $str)

## Answers

### Answer by Andrew Deniel

We can list which characters we DON'T want so just use a '^' as the first symbol in a bracket expression(i.e., "%[^a-zA-Z]%" matches a string with a character that is not a letter between two percent signs)."^[a-zA-Z]": a string that starts with a letter;"[0-9]%": a string that has a single digit before a percent sign;",[a-zA-Z0-9]$": a string that ends in a comma followed by an alphanumeric character. \
In order to be taken literally, you must escape the characters "^.[$()|*+?{\" with a backslash ('\'), as they have special meaning. On top of that, you must escape the backslash character itself in PHP3 strings, so, for instance, the regular expression "(\$|¥)[0-9]+" would have the function call: ereg("(\\$|¥)[0-9]+", $str)


---

Original Source: https://www.mindstick.com/interview/1763/how-we-list-which-characters-we-don-t-want-how-to-use-backslash-character

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
