Saravanan666/pypi-org huggingface dataset:
Package: regexfinder
RegexFinderThis is a 3-day zero-dependency project that finds regular expression for any piece of textHow to install:pip install regexfinderHow to import:from regexfinder import RegexFinderHow to use:CallRegexFinder, type inside the string you want to be regular expressed, andfind()!This module contains some parameters that you have to understand before using properly:descriptive- default is True. This means that the program will generate a regexp based on the format and length of the string, any minor change in format will not work adaptively. If you want a regexp that will work dynamically in other situations, turn this to False and utilize the below parameters as explained.document- paste here the full text if you want to find regexp of string based on actual environmentconstantPrecedingText- turn this to True if you have inserted a document, to create a regexp that is based on the textbeforethe pattern you want to find, that never changes.constantSucceedingText- turn this to True if you have inserted a document, to create a regexp that is based on the textafterthe pattern you want to find, that never changes.constantChars- To be able to find general regexp for a pattern of a string, you should declare one or more characters which will always appear in string, as constants. For example, if you want to find regexp of this string 'test="123"', which represents a key and a value, you should add as constantChar the '=', and both the ' " ', so the program can grasp from atleast somewhere what's going on and what the objective of the user is. This parameter takes as input list which contains indexes of characters that you want to be declared constant. Index of character starts from 0, as the first char of string, and goes on for the length of it. If you have trouble finding this indexes, call thehelp()function of this class and it will display the indexes for you. For the above example the input would look like this:constantChars=[4, 5, 9].Reason for these parameters is that finding and generating Regular Expressions programmatically without A.I is almost impossible, because the code can't deduct the purpose of the regex itself, it doesn't have logic, so the only solution is if you and the program work together, you throw the hints, RegexFinder does the heavy duty.So if you want a proper RegExp, make sure to do atleast one of these, whiledescriptive=False:add constants to constantCharsadd the document where string is located and specify if the text before or after is constantCode illustrations:For any idea or problem contact me.
Package: regex-generator-lib
Regex-GeneratorThis project was created as an experiment to see how accurately I can generate valid regex when simply given a string(s) to match.#How to use#Basic Example:from RegexGenerator import RegexGeneratormyRegexGenerator = RegexGenerator("123-555-7676")print(myRegexGenerator).get_regex()#Expected Output:\d{3}[-]\d{3}[-]\d{4}
Package: regex-hir
regex_hirA high-level intermediate representation of regex in Python.PyPi|Github SourceInstallationRequires Python >=3.10. Also requires theunicategorieslibrary for easy access to categorised Unicode characters.DescriptionThis library constructs an intermediate representation of the regex AST created by the built-inremodule. This functions similary to the Rustregex_syntaxcrate, which was completely the inspiration for this module.All of the syntax supported byreis supported by this module.Usageimportregex_hirhir=regex_hir.hir(r"[abc]")hir.dumps()# CharacterClass(#     [#         CharacterRange(start=97, end=97)#         CharacterRange(start=98, end=98)#         CharacterRange(start=99, end=99)#     ]#     negate=False#     ignore_case=False# )
Package: regexify
regexifyUtilities/containers for deploying regular expressions.Table of ContentsAbout the ProjectGetting StartedPrerequisitesInstallationUsageRoadmapContributingLicenseContactAcknowledgementsAbout the ProjectThis package contains a few useful functions and classes for building/using regular expressions.Getting StartedPrerequisitesPython 3.7+InstallationInstall using pip:pip install regexifyUsageSee the test files for example usage.Pattern TrieCompile multiple terms into a single pattern.importrefromregexifyimportPatternTriedata=['there','hi','python','pythons','hiya']trie=PatternTrie(*data)pat=re.compile(trie.pattern)VersionsUsesSEMVER.Seehttps://github.com/dcronkite/regexify/releases.RoadmapSee theopen issuesfor a list of proposed features (and known issues).ContributingAny contributions you make aregreatly appreciated.Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestLicenseDistributed under the MIT License.SeeLICENSEorhttps://dcronkite.mit-license.orgfor more information.ContactPlease use theissue tracker.Acknowledgements
Package: regex-learner
Regex-learnerThis project provides a tool/library implementing an automated regular expression building mechanism.This project takes inspiration on the paper from Ilyas, et al [1]Ilyas, Andrew, M. F. da Trindade, Joana, Castro Fernandez, Raul and Madden, Samuel. 2018. "Extracting Syntactical Patterns from Databases."This repository contains code and examples to assist in the exeuction of regular expression learning from the columns of data.This is a basic readme. It will be completed as the prototype grows.InstallationThe project can be installed via pip:pipinstallregex-learnerExamples of usageExample of learning a date pattern from 100 examples of randomly sampled dates in the format DD-MM-YYYY.fromxsystemimportXTructurefromfakerimportFakerfake=Faker()x=XTructure()# Create basic XTructure classfor_inrange(100):d=fake.date(pattern=r"%d-%m-%Y")# Create example of data - date in the format DD-MM-YYYYx.learn_new_word(d)# Add example to XSystem and learn new featuresprint(str(x))# ([0312][0-9])(-)([01][891652073])(-)([21][09][078912][0-9])Similary, the tool can be used directly from the command line using theregex-learnerCLI provided by the installation of the package.The tool has several options, as described by the help message:> regex-learner -h
usage: regex-learner [-h] [-i INPUT] [-o OUTPUT] [--max-branch MAX_BRANCH] [--alpha ALPHA] [--branch-threshold BRANCH_THRESHOLD]

A simple tool to learn human readable a regular expression from examples

options:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Path to the input source, defaults to stdin
  -o OUTPUT, --output OUTPUT
                        Path to the output file, defaults to stdout
  --max-branch MAX_BRANCH
                        Maximum number of branches allowed, defaults to 8
  --alpha ALPHA         Weight for fitting tuples, defaults to 1/5
  --branch-threshold BRANCH_THRESHOLD
                        Branching threshold, defaults to 0.85, relative to the fitting score alphaAssuming a data file containing the examples to learn from is calledEXAMPLE_FILE, and assuming one is interested in a very simple regular expression, the tool can be used as follows:catEXAMPLE_FILE|regex-learner--max-branch2NoteNote that this project is not based on the actual implementation of the paper as presented in [2]ReferencesIlyas, Andrew, et al. "Extracting syntactical patterns from databases." 2018 IEEE 34th International Conference on Data Engineering (ICDE). IEEE, 2018.https://github.com/mitdbg/XSystem
Package: regexlint
Regexlint is intended to be run as a linter against an importable Pygments
lexer, and flag problems that will prevent the lexer from performing well (since
we don’t have branch coverage for lexers :)As a simple example, alternations are first match, so it will flag this as never
matching “elseif”:(else|elseif)It also understands some Pygments internals, for examplebygroups(...)`needs to have the same number of args as the regex has capture groups.  Too many
will result in duplicate text; too few will result in missing text.  There
should also not be any gaps between the capture groups, so this example flags
two problems:(r'(foo)\s+(bar)', bygroups(Blah)),Usagemake demo
    or
regexlint pygments.lexers.web:HtmlLexer
    or
python3 regexlint/cmdline.py pygments.lexers.webTodoFigure out which phase should remove unnecessary backslashesWrite the alternation expander, so that ([ax]|a[bc]) fails the alternation
order checksMake more general than just for PygmentsLicenseThis project is licensed under the Apache Public License, see COPYING
Package: regex-llm
regex llmConstrained language model generation with regex.Installationpipinstallregex-llmUsageimportregexfromtransformersimport(AutoTokenizer,GenerationMixin,PreTrainedTokenizer,AutoModelForCausalLM,)fromregex_llmimportRegexConstraintmodel:GenerationMixin=AutoModelForCausalLM.from_pretrained("your model")tokenizer:PreTrainedTokenizer=AutoTokenizer.from_pretrained("your model")controller=RegexConstraint(tokenizer=tokenizer,model=model)prompt='帮我生成3种不同的水果\n输出json格式如下：\n[{"name":"xxx","description":"xxx"}]'pattern=r"\[(,?\s*\{\"name\":\s*\"[^\"]+\",\s*\"description\":\s*\"[^\"]+\"\\s*})+\s*\]"output=controller.generate(prompt=prompt,pattern=pattern,do_sample=True,num_beams=1,top_p=0.7,temperature=0.95,)print(output)
Package: regexmodel
regexmodelRegexmodel is a python package that uses a graph model to fit and synthesize structured strings.
Structured strings are strings such as license plates, credit card numbers ip-addresses, and phone numbers. Regexmodel can infer a regex-like structure from a series of positive examples and create new samples
(such as phone numbers etc.).Features:Draw new synthetic valuesOnly on the numpy and polar libraries (faker for benchmarks).Fast (on average < 1 second for about 500 positive examples).Can provide statistics on how good the regexmodel has fit your values using log likelihood.Can be serialized and can be modified by hand.InstallationYou can install regexmodel using pip:pipinstallregexmodelIf you want the latest version of git, use:pipinstallgit+https://github.com/sodascience/regexmodel.gitIf you want to run the benchmarks, you should also install the faker package:pipinstallfakerUsing regexmodelFitting the regexmodel is as simple as:fromregexmodelimportRegexModelmodel=RegexModel.fit(your_values_to_fit,count_thres=10,method="accurate")Thecount_thresparameter changes how detailed and time consuming the fit is. A higher threshold means
a shorter time to fit, but also a worse fit.Themethodparameter determines the performance/how fast the model is trained. For better looking results,
the "accurate" method is advised. If the quickness of the fit is more important, then you can use the "fast" method. The "accurate" method is generally slow with very long/branching/unstructured strings.Then synthesizing a new value is done with:model.draw()SerializationThe regex model can be serialized so that it can be stored in for example a JSON file:importjsonwithopen(some_file,"w")ashandle:json.dump(model.serialize(),handle)And deserialized:withopen(some_file,"r")ashandle:model=RegexModel(json.load(handle))
Package: regexparser
regexparserFrequently I have to parse text intofloat,intanddate, for a few examples.
TheTextParserclass to isolates the parsing task, instead of getting the parsing rules (or functions) spread all over the code.Installpip install regexparserpipinstall from github:pip install git+https://github.com/wilsonfreitas/regexparser.gitUsingCreate a class inheritingTextParserand write methods with names starting withparse.
These methods must accept 2 more arguments afterselfand those arguments are thetextthat will be parsed and theMatchObjectthat is returned by applying the regular expression to thetext.
Theparse*methods are called only if its regular expression is matched and their regular expressions are set in the methods' doc string.textparserprovides a compact way of applying transformation rules and that rules don't have to be spread out along the code.The following code shows how to create text parsing rules for a tew text chunks in portuguese.classPortugueseRulesParser(TextParser):# transform Sim and Não into boolean True and False, ignoring casedefparseBoolean_ptBR(self,text,match):r'^(sim|Sim|SIM|n.o|N.o|N.O)$'returntext[0].lower()=='s'# transform Verdadeiro and Falso into boolean True and False, ignoring casedefparseBoolean_ptBR2(self,text,match):r'^(verdadeiro|VERDADEIRO|falso|FALSO|V|F|v|f)$'returntext[0].lower()=='v'# parses a decimal numberdefparse_number_decimal_ptBR(self,text,match):r'^-?\s*\d+,\d+?$'text=text.replace(',','.')returneval(text)# parses number with thousandsdefparse_number_with_thousands_ptBR(self,text,match):r'^-?\s*(\d+\.)+\d+,\d+?$'text=text.replace('.','')text=text.replace(',','.')returneval(text)parser=PortugueseRulesParser()assertparser.parse('1,1')==1.1assertparser.parse('-1,1')==-1.1assertparser.parse('- 1,1')==-1.1assertparser.parse('WÃ¡lson')=='WÃ¡lson'assertparser.parse('1.100,01')==1100.01I copied the idea of using a regular expression in__doc__fromPLY.
Package: regex-patterns
Regex PatternsAn improved version of commonly used regular expressions in PythonInspired by and improved upon:CommonRegexCommonRegex ImprovedThis is a collection of commonly used regular expressions. This library provides a simple API interface to match the strings corresponding to specified patterns.Installationpipinstall--upgraderegex-patternsUsagefromregex_patternsimportRegexPatternspatterns=RegexPatterns()text=("John, please get that article on www.linkedin.com to me by 5:00PM on Jan 9th 2012. ""4:00 would be ideal, actually or 5:30 P.M. If you have any questions, You can ""reach me at (519)-236-2723x341 or get in touch with my associate at ""harold_smith@gmail.com. You can find my ip address at 127.0.0.1 or at ""64.248.67.225. I also have a secret protected with md5 ""8a2292371ee60f8212096c06fe3335fd. The internal webpage to get the article from is ""https://internal.sharepoint.edu.au")date_list=patterns.dates(text)# ['Jan 9th 2012']time_list=patterns.times(text)# ['5:00pm', '4:00 ', '5:30 P.M.']url_list=patterns.links(text)# ['www.linkedin.com', 'gmail.com', 'https://internal.sharepoint.edu.au']phone_list=patterns.phones_with_exts(text)# ['(519)-236-2723x341']ip_list=patterns.ips(text)# ['127.0.0.1', '64.248.67.225']email_list=patterns.emails(text)# ['harold_smith@gmail.com']md5_list=patterns.md5_hashes(text)# ['8a2292371ee60f8212096c06fe3335fd']Features / Supported Methodsdates(text: str)times(text: str)phones(text: str)phones_with_exts(text: str)links(text: str)emails(text: str)ipv4s(text: str)ipv6s(text: str)ips(text: str)not_known_ports(text: str)prices(text: str)hex_colors(text: str)credit_cards(text: str)visa_cards(text: str)master_cards(text: str)btc_address(text: str)street_addresses(text: str)zip_codes(text: str)po_boxes(text: str)ssn_numbers(text: str)md5_hashes(text: str)sha1_hashes(text: str)sha256_hashes(text: str)isbn13s(text: str)isbn10s(text: str)mac_addresses(text: str)iban_numbers(text: str)git_repos(text: str)
Package: regexplayground
Python re(gex)? playgroundThis TUI application is intended as an interactive playground for Python Regular Expressions. The app also includes a comprehensive cheatsheet and several interactive examples.ScreenshotGuideSeeapp_guide.mdLicenseCode snippets are licensed underMIT LICENSEExplanations and associated files (likecheatsheet.md) are licensed underCreative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Package: regexp-learner
regexp-learnerOverviewregexp-learneris aPython 3module providing the following algorithms:Angluin (1987):the L* algorithm is presented inLearning regular sets from queries and couterexamples, Dana Angluin, 1987 [pdf], [slides].Gold (1978):the Gold algorithm is presented inComplexity of automaton identification from given data, E. Mark Gold, 1987 [pdf].This module is built on top of:numpy;pybgl, a lightweight graph library.Ajupyter notebookis also provided test the algorithm. Note that thegraphvizrunnables (e.g.,dot) is required to display the automata.UsageInstallJupyter NotebookorJupyter lab.Followinstallation steps.Runjupyter notebookorjupyter lab.Open the desired notebook.Run the cells.LinksInstallationDocumentationCoverageWikiLicenseThis project is licensed under theBSD-3-Clause license.
Package: regex-replacer
Regex ReplacerThis is simple package for fast replace texts with regex.
Support Rust regex syntax:https://docs.rs/regex/latest/regex/#syntaxInstallationpipinstallregex_replace--upgradeUsagefromregex_replacerimportRegexReplacerTransformertransformer=RegexReplacerTransformer([(r'[0-9]+'," NUMBER "),(r"[a-z]+"," WORD ")])test_strings=["this is a SIMPLE TEXT 12345 with number"]print(transformer.transform(test_strings))# Output: [' WORD   WORD   WORD  SIMPLE TEXT  NUMBER   WORD   WORD ']for multithread transform:transformer=RegexReplacerTransformer([(r'[0-9]+'," NUMBER "),(r"[a-z]+"," WORD ")],n_jobs=3)to back to single thread:transformer.to_single_thread()
Package: regex-rs
regex-rsPython bindings for the rust regex crateUsagefromregex_rsimportRegexre=Regex(r"\d+")fornumber_matchinre.find_iter("1 2 34 123"):# number_match: regex_rs.Matchprint(number_match)# 1# 2# 34# 123Available methodsRegex.findRegex.find_iterRegex.capturesRegex.captures_iterRegex.splitRegex.replaceNoteThese bindings are missing a significant portion of the rust regex crate.
If you see a struct or method that you would like added, feel free to
open an issue for it.
Package: regex-spm
regex_spmEnable Structural Pattern Matching (PEP-634) for Python
regular expressionsThe string goes in the place of the subject, wrapped by aregex_spmfunction.The various possible regex patterns go after thecases.Simple exampleimportregex_spmmatchregex_spm.fullmatch_in("abracadabra"):caser"\d+":print("It's all digits")caser"\D+":print("There are no digits in the search string")case_:print("It's something else")regex_spmprovides 3 functions, which correspond toresearch functions:re.search→regex_spm.search_inre.match→regex_spm.match_inre.fullmatch→regex_spm.fullmatch_inAccessing the match objectTo access the matched groups or the entirere.Matchobject, simply capture the pattern:matchregex_spm.fullmatch_in("123,45"):caser"(\d+),(?P<second>\d+)"asm:print("Notice the `as m` at the end of the line above")print(f"The first group is{m[1]}")print(f"The second group is{m['second']}")print(f"The full `re.Match` object is available as{m.match}")Pattern caveats (workaround below)#1:Due to the mechanics of Python SPM, it is not possible to use case blocks likecase  re.compile(r"my-regex"): .... Python would try to usere.compileas a class name, which does not
exist.#2:It is also not possible to save patterns to simple local variables like:pattern1=r"my-first-pattern"pattern2=re.compile(r"my-second-pattern")matchregex_spm.search_in(my_string):casepattern1:print("This does not work, it matches any string. Python interprets `pattern1` ""as simply a new capture variable name, hiding its previous value.")casepattern2:print("This does not work either")Using patterns from variables (caveat workaround)Python requires "value patterns" to use a "dotted name", i.e. there must be a.in tha name used
to reach the stored pattern.Putting stored patterns in a class like below is sufficient.classPageRegexes:index=re.compile(r"example\.com/index.html")shopping_cart=r"example\.com/shopping_cart.html"matchregex_spm.search_in(my_url):casePageRegexes.index:print("It's the index page")casePageRegexes.shopping_cart:print("It's the shopping cart page")caser"example\.com/about.html":print("You can even mix and match")InstallRequires Python 3.10+ of coursepipinstallregex_spm
Package: regextypofix
RegEx Typo Fix====Regex spellchecker based on Wikipedia's `RegExTypoFix` project.. _RegExTypoFix: https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/TyposThe dictionary prepared by wikipedia contains most common incorrectly spelled words.Usage-----The easiest way to install it is using pip::pip install regextypofixfrom regextypofix import correctprint (correct('whiel selled'))Add more patterns-----You can either create your own dictionary or just append to the default dictionary::from regextypofix import correct, create_dictionary# Build default dictionarydefault_dictionary = create_dictionary()# User defined dictionaryuser_dictionary = create_dictionary('./path_to_text_files')# Complete dictionarydictionary = default_dictionary + user_dictionary# Now pass dictionary to `correct`correct('whiel selled', dictionary=dictionary)
Package: regfile-generics
regfile_genericsInstallationFrom PyPIpython3-mpipinstall--upgraderegfile_genericsFrom sourcegitclonehttps://github.com/icglue/regfile_genericscdregfile_generics
python3-mpipinstall.UsageSetup Regfile and Regfile Device for AccessSeetests/fixtures.pyhow to create a regfile by deriving from the Regfile class.
Implement read/write functions and pass them (or overwrite while deriving) to an adequateRegfileDeviceclass.Accessing Registers# dict like:regfile["reg1_high"]={"cfg":0x0AA,"cfg_trigger":0x0,"cfg_trigger_mode":0x0}# or single field (might issue read-modify-write)regfile["reg1_high"]["cfg"]=0xB# uvm like:regfile.reg2_r.config_f.set(2)regfile.reg2_r.update()# write_updateregfile["reg_addr40_r"].write_update(start=1,enable_feature0=0,enable_feature1=0)# read (can be int or dict or string context)assertentry["cfg"]==0x22print(entry["cfg"])# read entire entry to an variable, so that no further read request will be issued
Package: regfmt
regfmtregfmtis a command line utility to generate SVG diagrams for control register-style data formats. It is inspired by thedformatcommand from thetrofffamily of tools, however re-imagined using contemporary (circa 2022) file formats.Example output SVG:FeaturesSVG outputModern configuration input file formatsYAML for register configurationCSS for styling SVG outputUsageusage: regfmt [-h] [-v] [-o OUTPUT] [-s STYLE] [-t {yaml,css,yamlcss}] [input]

regfmt - generate SVG diagrams of control register-style data formats

positional arguments:
  input                 input register format YAML file (default: input.yaml)

options:
  -h, --help            show this help message and exit
  -v, --version         print version information and exit
  -o OUTPUT, --output OUTPUT
                        output file (default: '-' for stdout)
  -s STYLE, --style STYLE
                        CSS style file
  -t {yaml,css,yamlcss}, --template {yaml,css,yamlcss}
                        Generate template YAML and/or CSS files
Package: reggaeton
ReggaetonReggaeton is a visual regression tool designed to compare two images and highlight the differences with a visual indication. It's particularly useful for identifying changes or anomalies in visual content over time or between versions.InstallationYou can install Reggaeton directly from PyPI:pipinstallreggaetonThis command will install Reggaeton and its dependencies.UsageReggaeton can be used both as a library in your Python scripts and as a command-line tool.As a Command-Line ToolAfter installation, you can use Reggaeton directly from your terminal:reggaetonpath/to/before/image.jpgpath/to/after/image.jpgpath/to/output/image.jpgThis command compares before and after images and saves the output image with differences highlighted to the specified path.As a LibraryYou can also use Reggaeton in your Python scripts:fromreggaetonimportcompare_imagesresult_image=compare_images('path/to/before.jpg','path/to/after.jpg')ifresult_imageisnotNone:# Save or process result_image as neededContributingContributions are welcome! Please feel free to submit a pull request.LicenseReggaeton is released under the MIT License. See the LICENSE file for more details.