Posts

Showing posts with the label replace

Replace character string between new lines

Image
Clash Royale CLAN TAG #URR8PPP Replace character string between new lines I am trying to edit a file such that strings flanked by new lines are removed. My file looks like: ENSG00000000460_chr1.dat varX data data data data data varX data data data data data varX data data data data data ENSG00000005801_chr11.dat ENSG00000006007_chr16.dat ENSG00000006607_chr2.dat varX data data data data data varX data data data data data ENSG00000010219_chr12.dat ENSG00000011052_chr17.dat The output I am trying to get would delete lines which are flanked by new lines (and delete the new lines) resulting in output which looks like: ENSG00000000460_chr1.dat varX data data data data data varX data data data data data varX data data data data data ENSG00000006607_chr2.dat varX data data data data data varX data data data data data I have tried various ideas in sed, but it either returns: sed 's/[na-zA-Z0-9n]//g' file.txt | head _. . .- . . . . . . .-...

jQuery messes up line breaks

Image
Clash Royale CLAN TAG #URR8PPP jQuery messes up line breaks I've got an if else statement. Switching between a text in <p> tag and the same text in an editable <textarea> <p> <textarea> The problem is that: you press the edit button and script converts p tag to textarea. Text is converted fine with line breaks. You press save. Text is converted correctly back into a p tag again. You try to press edit again... but this time, the linebreaks are ignored!? var curState = "Ret"; if (curState == "Gem"){ curState = "Ret"; var p = btn.closest("div").find("textarea"); var t = jQuery(this).closest("div").children("div").children('textarea').val().replace(/(rn|n)/g, "<br/>"); var ta = jQuery("<p/>", { "html": t }); p.replaceWith(ta); }else{ curState = "Gem"; var p = jQu...

How to replace a Text with a pipe character

Image
Clash Royale CLAN TAG #URR8PPP How to replace a Text with a pipe character I want to replace a String with a Pipe delimiter but it doesnt seem to work. String tagData = "Name:Test,Code:312341,ID:4 |"; String s = "Name:sqeq,Code:34311,ID:5 |Name:qddas,Code:43134,ID:6 |Name:Test,Code:312341,ID:4 |"; i have tried: s = s.replaceAll(tagData, ""); s = s.replace(tagData, ""); s = s.replaceFirst(tagData, ""); nothing of these Methods changed anything on my string. s = s.replace(tagData, ""); works. What do you want? – Mạnh Quyết Nguyễn 22 secs ago s = s.replace(tagData, ""); By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy...