Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Sometimes underline char is duplicated #26

Open
EmilyGraceSeville7cf opened this issue Oct 11, 2021 · 4 comments
Open

Sometimes underline char is duplicated #26

EmilyGraceSeville7cf opened this issue Oct 11, 2021 · 4 comments

Comments

@EmilyGraceSeville7cf
Copy link

EmilyGraceSeville7cf commented Oct 11, 2021

OS version: Linux Mint 20.2 Cinnamon
Bulky version: 1.7

Steps to reproduce:

  1. Create to files with 1 and 2 names respectively.
  2. Put (.*) and \1_ into Find and Replace fields respectively. (Replace mode is Name only)
  3. Obtain 1__ and 2__ names respectively.
@MuenchenSued
Copy link

Seems to be the normal behavior of regular expressions.
grafik

You can usr (.+) or ^(.*) for the correct result.

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Jan 10, 2022

But string replace --regex '(.*)' '$1_' 1 produces exactly one underscore instead of two. It uses PCRE2 flavor. 🤔

@fenilgmehta
Copy link
Contributor

It is because of the way python's re library works.

>>> import re
>>> re.findall(r'(.*)', 'abcde')
['abcde', '']

The empty string in the result is causing the double underscore.
Using (.+) or ^(.*)$ instead of (.*) will fix the issue.

@EmilyGraceSeville7cf
Copy link
Author

Thanks for the answer! But am not sure whether such behavior is intuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants