Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14069

How to reverse regex pattern?

$
0
0

Let's say I have this string:

exampleString = 'Hello @world! This is a #sample ^string 5with @words that ^start with symbols.'

And I want to print all words that does not start with any symbol.

pattern = '[@^#!%&*].*?\s'

I've got this pattern that selects all words that starts with any kind of symbol. And now comes my question: How to reverse it so it matches the exact opposite?

I tried (?!) but it seems to do nothing.


Viewing all articles
Browse latest Browse all 14069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>