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

Search/Replace - Regex Issue Escaped Characters #679

Closed
caseychambliss opened this issue Apr 5, 2023 · 10 comments
Closed

Search/Replace - Regex Issue Escaped Characters #679

caseychambliss opened this issue Apr 5, 2023 · 10 comments

Comments

@caseychambliss
Copy link

caseychambliss commented Apr 5, 2023

Acode Version: 1.8.1 (274)
OS: Android 13

When using the Search/Replace dialog the replace with escaped characters such as

  • \n
  • \r
  • \t

the replacement is with these literal characters of:

  • "\n" instead of a new line character
  • "\r" instead of a return character
  • "\t" instead of a tab character

The replace field does seem to work for other regular expressions such as back reference, so I believe the issue is only with escaped characters.

This was called out previously in another issue over a year ago, but resubmitting after re-explaining.

I would be happy to donate to this project if this can be addressed.

@caseychambliss
Copy link
Author

caseychambliss commented Apr 5, 2023

I'm not a programmer, but looking at this file starting on line 145 may be where to start looking.

Acode/src/handlers/quickTools.js

case 'replace':
  editor.replace($replaceInput.value || '');
  break;

case 'replace-all':
  editor.replaceAll($replaceInput.value || '');
  break;

@caseychambliss
Copy link
Author

I'm not a programmer, but looking at this file starting on line 145 may be where to start looking.

Acode/src/handlers/quickTools.js

case 'replace':
  editor.replace($replaceInput.value || '');
  break;

case 'replace-all':
  editor.replaceAll($replaceInput.value || '');
  break;

From what little I know and what I see here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

There may be a need to encapsulate the replacement text with the "/" character on the beginning and end of the text string when the Regular Expressions toggle is selected.

Also, the syntax of the replace arguments looks to be different than the documentation.

These are all guesses on my part.

@RaSan147
Copy link

RaSan147 commented Apr 8, 2023

It seems the find and replace is missing multiline functionality. Since search has an entire personal bar, i would be great to have multi line find and replace. We won't mind if thats moved to settings.
I'll try checking if there's any way i can implement that.

@RaSan147
Copy link

RaSan147 commented Apr 8, 2023

Acode Version: 1.8.1 (274) OS: Android 13

When using the Search/Replace dialog the replace with escaped characters such as

  • \n
  • \r
  • \t

the replacement is with these literal characters of:

  • "\n" instead of a new line character
  • "\r" instead of a return character
  • "\t" instead of a tab character

The replace field does seem to work for other regular expressions such as back reference, so I believe the issue is only with escaped characters.

This was called out previously in another issue over a year ago, but resubmitting after re-explaining.

I would be happy to donate to this project if this can be addressed.

Something to note, not even VS code parse \n to newline in replace, they keep it like it is what it is. (And there are reasons for it too) but a toggle or an multiline + \t + \r supported character find and replace bar is what we actually need.

@deadlyjack
Copy link
Collaborator

I'll see what can be done. Thanks for reporting.

@mpmcpherson
Copy link

To add my use case: I will often paste large tracts of text into a file I'm editing (for example, when I'm prototyping something and I want to pull in a reasonable dataset for testing -say, a couple hundred key-value pairs- without having to stand up a database and db connection) which I then need to sanitize and format.

In sublime text, I would use a regex to properly format the data, to replace certain newlines with commas or colons, etc. Not being able to do this sort of transformation is a real problem if I want to use this for quick and dirty proof of concept programming.

Are you already working on a feature branch for this? I'd be happy to contribute some of my time.

@deadlyjack
Copy link
Collaborator

deadlyjack commented Jun 3, 2023

Newer version of app as search in all files feature, which support multiline too. The feature is in beta version but you can try it. Read more https://github.com/deadlyjack/Acode/blob/main/CAHNGELOG.md

@mpmcpherson
Copy link

I see that there are two versions of this application in the app store. Is the other one the beta version? Am I going to have to pay for it again to remove ads from the beta?

@deadlyjack
Copy link
Collaborator

deadlyjack commented Jun 3, 2023 via email

@sekedus
Copy link

sekedus commented Nov 18, 2024

Tracking this in an existing issue #280

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

5 participants