i've got a document with 38.000 lines.
I'd like to add a <div class="kalle"> in front of each line which contains the word "Kalle" and a <div class="susi"> in front of each line which contains the word "Susi".
Can you help me how to solve this problem?
Type Ctrl+H, then
Find what: ^(.*)(Kalle|Susi)
Replace with: <div class="$2">$1
or
Replace with: <div class="$2">$1$2 if you want to keep kalle and susi in the string
Regular Expression must be checked but NOT dot matches newline
Related
I am trying to match a url string and I want to swap when some word is included in this case reviews the problem is that when the url ends on a forward slash my formula adds a double slash. Is there a way to add a slash only when there is no slash at the end?
https://regex101.com/r/cjMEiW/1
Is there a way to add a slash only when there is no slash at the end?
The 'trick' is to use an additional 'dummy' (not used in substitution) group (\/?) which can be empty or contain a slash and not to allow the group 3 to include a slash at its end (.*[^\/$])
See:
https://regex101.com/r/nysBYY/2
Regex:
(<a href='https:\/\/www\.example\.com)\/(reviews)\/(.*[^\/$])(\/?)('>)
Test string:
<a href='https://www.example.com/reviews/citroen/c4/'>here</a>
<a href='https://www.example.com/reviews/citroen/c4'>here</a>
Substitution:
$1/$3/$2/$5
Output:
<a href='https://www.example.com/citroen/c4/reviews/'>here</a>
<a href='https://www.example.com/citroen/c4/reviews/'>here</a>
Check out the answer https://stackoverflow.com/a/72516646/7711283 at Regex, substitute part of a string always at the end for more detailed explanation of the regex of the groups.
P.S. the OPs regex was:
(<a href='https:\/\/www\.example\.com)\/(reviews)\/(.*)('>)
with substitution $1/$3/$2/$4 which resulted in:
<a href='https://www.example.com/citroen/c4//reviews/'>here</a>
<a href='https://www.example.com/citroen/c4/reviews/'>here</a>
I am using Hygen to populate template files and want to print an array of strings eg.
[`'${item}'`]
but the single quotes are being converted to '
All other special characters are unaffected but single or doublequotes get converted so I'm not sure what's going on.
Turns out
<%= %>
tags in the template file escapes some characters, whereas...
<%- %>
does not!
I have an HTML file which contains the below code snippet.
<div class="col-sm-2 col-sm-offset-1">
<div class="countBox success" id="success">
<h2>467</h2>
Passed Tests
<span class="glyphicon glyphicon-eye-open"></span>
</div>
</div>
I have a regular expression (.*)</h2>\r\nPassed to get the value 467. It is worked till yesterday. But, it is not working now. I have tried by replacing single slash by double slash to new line and row. Used "\s+" to cover whitespace. All failed in error. Could anyone please guide me on how to get the value as 467 by using regular expression for the above code snippet?
It is better to catch <h2>(\d+)</h2> to ensure only a h2 header with a number inside. By the way, \r\n is only one convention (in windows) to represent end of line, but in unix it is only \n so to be more platform independent, you can do \r?\n (marking the \r as optional) and you have to get on the whitespace in front of Passed., so a good (but not probably the best) regexp would be:
<h2>(\d+)<\/h2>\r?\n\s*Passed
See demo.
I have this line in my jade file where i want to set the value #{target} but I get an error when it renders that this is illegal
input(type='hidden' name='target' value=#{target})
I believe this should be:
// note the double qoutes around `#{}`
input(type="hidden" name="target" value="#{target}")
Remove #{}. It should be value=target.
I just tried this and you couldn't use interpolation, it worked like this for me:
input(type="hidden" name="upload" id="upload" value=upload._id)
i believe my question is quite simple:
I have a string, for example,
" this is a string containing silly characters like " and <<< and >>> and hey look a hyperlink http://www.google.com"
My question is how can I prepare this string to be displayed on an MXML view, using AS3?
any help is greatly appreciated!
http://forums.adobe.com/thread/756042
http://cookbooks.adobe.com/post_Hyperlink_Control-13867.html
These link gives you a information about how to create single link without any text like http://www.google.com/May these link will be helpfull to create a link!
But you problem looks different, so first you have to make html string with all of the text and where you want a link at that point you must put a <A> tag with required attribut and where you want a special character you must use its hex code or escape sequence of html like for & = &. my meaing is to say that make a html string without head tag. then give this string to <s:RichEditableText> see example.
First Way.
<s:RichEditableText>
<s:content>
<s:p>
Here is a link: <s:a href="www.google.com"</s:a>
</s:p>
</s:content>
</s:RichEditableText>
Second way.
//Your Actionscript code.
[Bindable] private var _testString:String= "<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="16" COLOR="#000000" LETTERSPACING="0" KERNING="0">" this is a string containing silly characters like <and > they look a hyperlink <FONT COLOR="#0000FF"><B><I><U>http://www.google.com</U></I></B></FONT>"</FONT></P></TEXTFORMAT>";
// your mxml content
<mx:RichTextEditor id="richEditableText1"
width="100%"
htmlText="{testString}"
height="100%"/>
Good Luck!