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

[pebcak?/bug] Capture groups not working as expected? #348

Open
lcpichette opened this issue Oct 22, 2024 · 0 comments
Open

[pebcak?/bug] Capture groups not working as expected? #348

lcpichette opened this issue Oct 22, 2024 · 0 comments

Comments

@lcpichette
Copy link

Minimal reproducible issue

I think I used a pretty simple regex search and replace for my first time using sad, I could be mentally choking, but (job) should be a valid capture group in the search string for text job which can be referred to as $1 in the replace string.

[email protected]

Additional context

"Why not just use job instead of $1?" --> I'm trying to make the example as simple as possible. My use-case actually needs something more like ([a-zA-Z\-]+). So I'd like to find a working example that's as close to what I'm actually wanting as possible.

Here's what I need to end up running:

fd '.*\.js' | sad "strapi\.services\.([a-zA-Z\-]*)\.((create)|(update)|(findOne))\(([a-zA-Z\":'\s{}]*)\)" "strapi.entityService.$2('api::$1.$1',$6);"

Here's showing the search and replace pattern working in a teser:

2024-10-22@14 56 23 October-22@2x


Census

Even in the most simple of examples (see below) anything in the search capture group (e.g. (.*) should be usable in the replace string as $n (e.g. $1). So fd '.*\.js' | sad "\.(.*)\." ".$1." -> Should pipe all js files recursively in my current pwd to sad (which it does) and find anything with .<literally anything>. and replace it with .<that same literally anything>. (noop) -- but instead it finds .<literally anything>. (good) and replaces it with .. (as if the capture group is incorrect, but it's the exact same pattern as shown #44 (comment))

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

No branches or pull requests

1 participant