Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Berry add searchall() and matchall() to re module and pre-compiled patterns #18429

Merged
merged 1 commit into from
Apr 16, 2023

Conversation

s-hadinger
Copy link
Collaborator

Description:

Berry add matchall() and searchall() to pre-compiled patterns:

  • <rr>.searchall(hay:string [, limit:string]) -> list(list(string)): returns the list of searches. limit allows to limit the number of matches
  • <rr>.matchall(hay:string [, limit:string]) -> list(list(string)): returns the list of matches. limit allows to limit the number of matches.
  • searchall: pattern can match anywhere. matchall: pattern must match one after the other
import re
var rr = re.compile('<([a-zA-Z]+)>')

r = rr.searchall('<abc> yeah <xyz>')
# [['<abc>', 'abc'], ['<xyz>', 'xyz']]

r =  rr.matchall('<abc> yeah <xyz>')
# [['<abc>', 'abc']]

r =  rr.matchall('<abc><xyz>')
# [['<abc>', 'abc'], ['<xyz>', 'xyz']]
# there is no gap between each match

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works with Tasmota core ESP32 V.2.0.7
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@s-hadinger s-hadinger merged commit de45a7a into arendst:development Apr 16, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant