Giter Site home page Giter Site logo

Newline substitution. about regexr HOT 9 CLOSED

gskinner avatar gskinner commented on August 19, 2024
Newline substitution.

from regexr.

Comments (9)

gskinner avatar gskinner commented on August 19, 2024

Right, we currently limit the Expression and Substitution fields to single line input. I've considered treating the Substitution value as a Javascript string, so you can use "\n" and other encoded characters. Open to feedback on this.

from regexr.

thorsummoner avatar thorsummoner commented on August 19, 2024

This is the originating request: http://stackoverflow.com/questions/22751526/regexr-com-substitution-with-new-line-feed I'm sure "peter-lee" on SO would love to talk to you more about it :)

from regexr.

 avatar commented on August 19, 2024

Great tool, but newline/tab substitution is the thing I stuck with.

from regexr.

gskinner avatar gskinner commented on August 19, 2024

This also causes inconsistencies with the Share>Copy>Javascript workflow, because \n in the substitution is not decoded in RegExr, but is in JS.

To resolve this, I propose leveraging JSON.parse to decode escaped characters, and adding support to the SubstLexer to include highlighting / tooltips for them as well (ideally sharing code with the RegExLexer). I might take a stab at this when I have some time.

JSON.parse('"'+subst+'"'); // should decode all escaped chars.

from regexr.

gskinner avatar gskinner commented on August 19, 2024

A little more info: This seems like a better solution, but requires appropriate error handling:

try { str = eval('"'+str.replace(/"/g,'\\"')+'"')); } catch(e) { /* etc */ }

from regexr.

drogo007 avatar drogo007 commented on August 19, 2024

The ability to clean up data (including newlines) and format text is the primary reason I tend to use regexr. I don't use regexp often enough to remember all the rules off the top of my head, so having regexr makes life very easy - except I can no longer insert special characters in the substituion. Which renders 2.0 almost completely broken for all my use cases.

from regexr.

gskinner avatar gskinner commented on August 19, 2024

I just pushed a solution to this, supporting all JS escaped character formats, with appropriate errors and tooltips. This should be live in the next couple days.

from regexr.

gskinner avatar gskinner commented on August 19, 2024

This is now active on the live site. I'd love any feedback you have.

from regexr.

drogo007 avatar drogo007 commented on August 19, 2024

So a quick look this morning shows the new site now works like a charm for the kinds of things I tend to use Regexr for. Thank you!

from regexr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.