Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

regex

Escaping regex string

August 22, 2022 by Magenaut

I want to use input from a user as a regex pattern for a search over some text. It works, but how I can handle cases where user puts characters that have meaning in regex?

Categories Python, Q&A Tags python, regex Leave a comment

How to match a whole word with a regular expression?

August 22, 2022 by Magenaut

I’m having trouble finding the correct regular expression for the scenario below:

Categories Python, Q&A Tags python, regex Leave a comment

How to use a variable inside a regular expression?

August 21, 2022 by Magenaut

I’d like to use a variable inside a regex, how can I do this in Python?

Categories Python, Q&A Tags escaping, python, python-3.x, regex, variables Leave a comment

Speed up millions of regex replacements in Python 3

August 21, 2022 by Magenaut

I have two lists:

Categories Python, Q&A Tags performance, python, regex, replace, string Leave a comment

How to input a regex in string.replace?

August 21, 2022 by Magenaut

I need some help on declaring a regex. My inputs are like the following:

Categories Python, Q&A Tags python, regex, replace, string Leave a comment

How to correctly sort a string with a number inside?

August 21, 2022 by Magenaut

I have a list of strings containing numbers and I cannot find a good way to sort them. For example I get something like this: something1 something12 something17 something2 something25 something29 with the sort() method. I know that I probably need to extract the numbers somehow and then sort the list but I have no … Read more

Categories Python, Q&A Tags python, regex, sorting, string Leave a comment

How to find overlapping matches with a regexp?

August 21, 2022 by Magenaut

(?=...) matches if ... matches next, but doesn’t consume any of the
string. This is called a lookahead assertion. For example,
Isaac (?=Asimov) will match 'Isaac ' only if it’s followed by 'Asimov'.

Categories Python, Q&A Tags overlapping, python, regex Leave a comment

How can I find all matches to a regular expression in Python?

August 21, 2022 by Magenaut

In a program I’m writing I have Python use the re.search() function to find matches in a block of text and print the results. However, the program exits once it finds the first match in the block of text.

Categories Python, Q&A Tags python, regex, search Leave a comment

In Python, how do I split a string and keep the separators?

August 21, 2022 by Magenaut

Here’s the simplest way to explain this. Here’s what I’m using:

Categories Python, Q&A Tags python, regex Leave a comment

Word boundary with words starting or ending with special characters gives unexpected results

August 21, 2022 by Magenaut

Say I want to match the presence of the phrase Sortesindex[persons]{Sortes} in the phrase test Sortesindex[persons]{Sortes} text.

Categories Python, Q&A Tags python, regex Leave a comment
Older posts
Newer posts
← Previous Page1 … Page6 Page7 Page8 … Page20 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress