python-pcre | Python bindings for PCRE regex engine | Regex library
kandi X-RAY | python-pcre Summary
kandi X-RAY | python-pcre Summary
Python bindings for PCRE regex engine.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Expand a template
- Performs a substitution on a string
- Find all matches in string
- Substitute subn
- Converts a regular expression into a regular expression
- Escapes a template
- Compile a pattern
- Apply subn
- Returns True if pattern matches pattern
- Create Match object
- Apply pattern substitution
- Compile a regular expression
- Search string using finditer
- Find all occurrences of a pattern
- Split a string
- Split a string into parts
- Search string using regular expression
- Search string
python-pcre Key Features
python-pcre Examples and Code Snippets
Copyright (c) 2012-2015, Arkadiusz Wahlig
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retai
Community Discussions
Trending Discussions on python-pcre
QUESTION
So first question I've ever asked on here, and its about emojis. I'm sorry.
I am making a twitter bot in python with the help of Tweepy, and regex ( also tried python-pcre ) that will analyse a tweet of a given user, and record the number of times a word or emoji was used. I can do most of this just fine. My problems start with the emojis.
I was under the impression that when using \X, (in both regex and python-pcre) will find the eXtended grapheme clusters. Not just the individual ones. I read in another post What does the expression \X match when inside a RegEx? that \X follows a set of guidelines to determine if the next char should be clustered, but will always return at least 1.
I tried the first and second solution over at this post: How to extract all the emojis from text?.
The first one acted as expected. Grabs individual code-points and adds them to a list. Perfect for single code-point emojis, but I need to capture emojis with multiple code-points, and single code-point emojis.
The second solution one is where I am having problems. According to the post this function should print the emojis in a string, in clusters, separated by spaces.
...ANSWER
Answered 2020-Mar-04 at 10:00Note that \X
matches a single code point, but emojis may contain more than one, you yourself mention it in the question.
You should use an emoji parsing library that you are already using to get the emojis out of the text.
Use re
, no need for regex
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python-pcre
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page