3
I would like someone to help me create an ER that takes only one tag and all lines that are indented in front.
example:
aaa
abab aca
marcacao
aaa
abab aca
cc
cc
bb
With the above code the ER would return:
marcacao
aaa
abab aca
cc
My code is written in Javascript so I use . match() in my Ers.
[edited]
I described my problem better in the comments below.
That’s my real code:
DOCTYPE html
html
head
title gulp-gotohead
style.
article {border:1px solid}
style(data-above-the-fold="true").
body {font-size:100%}
body{font-size:100%}
body.main{font-size:100%}
body, h1{font-size:100%}
body>h1{font-size:100%}
header {color:#333}
script(data-above-the-fold="true").
var head = Head();
head();
body (data-d="true")
h1 gulp-gotohead
p
span regex
This is my appointment:
style(data-above-the-fold="true")
And this is the desired return:
style(data-above-the-fold="true").
body {font-size:100%}
body{font-size:100%}
body.main{font-size:100%}
body, h1{font-size:100%}
body>h1{font-size:100%}
header {color:#333}
The most I can get is to get my dialling codes down http://regex101.com/r/mZ2xS4/1.
How are you capturing this text? from HTML? can you put HTML in for testing? I won’t answer without HTML to be sure, but I imagine it’s something like this: http://regex101.com/r/sH4mZ1/1
– Sergio
Would use regex would not be a XY problem?
– Bacco
Javascript != HTML, @Sergio. No HTML required to use Javascript and
RegExp
.– sergiopereira
Bacco is right, I will try to explain my real problem. I am developing a plugin for Gulp that automates the task of placing CSS and JS codes inside the HEAD tag of an HTML document. When the source is in pure HTML it is easy to create an ER to identify my markup and exchange the old code for the new one. The problem occurs when the code is written in Jade, where the HTML tags can be very similar to CSS markings and JS scripts. I’m having trouble finding an ER that only picks up my markup ignoring the rest of the file’s source code.
– Belchior Oliveira
@sergiopereira, yes true, I know. Hence my question to Belchior about "where the content/ text comes from"
– Sergio
@Belchioroliveira now that you have revealed that you really want to create or consume a specific syntax, I would agree with Bacco and would avoid Regexp in this case. I would suggest ANTLR and ANTLR-Javascript. There is a considerable learning curve with this tool but it exists exactly for this purpose.
– sergiopereira