Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ignore only one special characters in regex

this is a general question to write a regular expression to exclude only one special characters. Let’s take this example: Note that the question is not related to bullet point.

regx = r'(?<=\*\)\s)[\w\s,\.]+'

re.findall(rr, '*) Do you like, pizza, salmon and fruits? *) Yes, I like Pizza and fruits, but I dont like salmon')

['Do you like, pizza, salmon and fruits? ',
 'Yes, I like Pizza and fruits, but I dont like salmon']

Here, I have to specify ,, . and ? to match correctly. In general, we can get other special characters. So, I want to include all the characters and exclude only *. I try this, but it does not work:

regx = r'(?<=\*\)\s)[\w\W^*]+'

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Have you tried it this way?
I think all characters except * can also be specified like this [^*]. See below:

Using regex to match any character except =

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading