Is there any principle to use "--" (incremental slide) properly on xaringan? - r-markdown

Whenever I use -- to generate incremental slides. Sometimes it works but sometimes not.
For example, the following codes work different way. It seems -- works in very random way. I was wondering if there's suggested way to use this sign.
blah blah
--
blah blah
or
blah blah
--
blah blah

It's not random and the issue you are having is actually how markdown works and has nothing to do with --. So which one you should use depends on what you want to do. But mostly people want to show list items incrementally and in that case, you have to use the 2nd approach i.e. use space before and after --
Explanation
The first thing we need to understand is that -- simply put the contents written after this in the next slide. It's simple as that.
So if we write the text in markdown in such a way that it will continue to be on the same line, then using --, the texts will continue to be in the same line in the next slide, and if we write text in markdown in a way that text will be in a separate line, then using -- will have the same effect, but text written after -- will be in the next slide.
To make this clear with an example, say I have written text like this (notice no space between the lines)
blah blah
foo bar
They will be rendered in the same line (due to no space) like this,
blah blah foo bar
So if I use -- in this case between these two line like this,
blah blah
--
foo bar
So in the first slide, we will have
blah blah
and in the second slide
blah blahfoo bar
That is, in the next slide, the text continues to be on the same line. Also, note that there's no space between blah blah and foo bar. To create a gap,
we have to give one space before or after --. So as either,
blah blah
--
foo bar
or
blah blah
--
foo bar
In both cases, the text on 1st slide will be blah blah and 2nd slide blah blah foo bar. So in the case of incremental slides, a single space between two lines of text amounts to a space between the words in the same line.
Now in markdown, to create write text on a new line you have to use a space explicitly. So
blah blah
foo bar
will be rendered as two separate lines
blah blah
foo bar
So similarly, while creating incremental slides, you have to give at least two spaces in total between the texts. So,
blah blah
--
foo bar
or
blah blah
--
foo bar
or
blah blah
--
foo bar
all three approaches create on the 1st slide,
blah blah
and on the 2nd slide,
blah blah
foo bar
Hope I haven't created more confusion instead of making things clear.

Related

regex registry replace

I have bunch of windows registry .reg files and would like to make some changes into them, replacing SID with HKCU.
files look like this:
[-HKEY_USERS\S-1-5-21-**********-********-*********-500\SomeKey\SomeSubKey]
blah blah blah
[-HKEY_USERS\S-1-5-21-**********-********-*********-500_Classes\SomeKey\SomeSubKey]
[HKEY_USERS\S-1-5-21-**********-********-*********-500\SomeKey\SomeSubKey]
blah blah blah
[HKEY_USERS\S-1-5-21-**********-********-*********-500_Classes\SomeKey\SomeSubKey]
and the expected result would be like this:
[-HKEY_CURRENT_USER\SomeKey\SomeSubKey]
blah blah blah
[-HKEY_CURRENT_USER\Software\Classes\SomeKey\SomeSubKey]
[HKEY_CURRENT_USER\SomeKey\SomeSubKey]
blah blah blah
[HKEY_CURRENT_USER\Software\Classes\SomeKey\SomeSubKey]
I basically know what should be done but as regex is not my language maybe someone will help me :)
The idea is to search at the beginning of the line for [HKEY or [-HKEY
continue until *-500
replace HKEY* until *-500 with HKEY\.
Of course there is 500 vs 500_Classes and Software thing, but if given right direction I could figure out that myself or do a double run.
I would use Notepad++ for this.
Find
\[(-)?HKEY_USERS\\S-1-5-21-.{10}-.{8}-.{9}-500(_Classes)?(.*)
and replace with
[$1HKEY_CURRENT_USER(?{2}\\Software\\Classes)$3

Regexextract over multiple lines within one cell

In Google Sheets, I have this in one cell:
Random stuff blah blah 123456789
<Surname, Name><123456><A><100><B><200>
<Surname2, Name2><456789><A><300><B><400>
Some more random stuff
And would like to match the strings within <> brackets. With = REGEXEXTRACT(A4, "<(.*)>") I got thus far:
Surname, Name><123456><A><100><B><200
which is nice, but it is only the first line. The desired output would be this (maybe including the <> at the beginning/end, it doesn't really matter):
Surname, Name><123456><A><100><B><200>
<Surname2, Name2><456789><A><300><B><400
or simply:
Surname, Name><123456><A><100><B><200><Surname2, Name2><456789><A><300><B><400
How to get there?
Please try:
=SUBSTITUTE(regexextract(substitute(A4,char(10)," "),"<(.*)>"),"> <",">"&char(10)&"<")
Starting in the middle, the substitute replaces line breaks (char(10)) with spaces. This enables the regexextract the complete (ie multi-line) string to work on, with the same pattern as already familiar to OP. SUBSTITUTE then reinstates the relevant space (identified as being immediately surrounded by > and <) with a line break.
Google sheets uses RE2 syntax. You can set the multi-line and s flags in order to match multiple lines. The following will match all characters over multiple lines in cell A2.
=REGEXEXTRACT(A2, "(?ms)^(.*)$")
REGEXEXTRACT(A1,"text1(?ms)(.*)text2")
So, in this case:
REGEXEXTRACT(A1,"<(?ms)(.*)>")

Vim: Delete all text surrounded by a start and an end

Say I've got this:
\item[1]\footnote{«footnote blah blah»}
footnote blah blah.
\item[2]\footnote{«blah blah footnote»}
random text
\item[3]\footnote{«this is not»}
more random text
I want to quickly delete \footnote{*} (that includes \footnote{«footnote blah blah»} \footnote{«blah blah footnote»} and \footnote{«this is not»}, but not \item[x] or the lines below that. How is this achieved?
Thanks!
I think the most accurate way would be to use:
:%s/\\footnote{.\{-}}//g
This will delete footnote and everything in between the braces. Using {.*} will delete everything up to the last brace even if it is outside of the footnote brace.
In escape mode
:1,$s/\\footnote{.*}//g

Replace contiguous line feeds or new line characters with a single newline in Flex

I need to replace multiple contiguous new line/line feed characters in flex with a single new line character.
Example:
The string
"My name is blah blah \n\n\n\n
My name is blah \r\n\r\n\r\n"
Should be converted to
"My name is blah blah \n
My name is blah \n"
Hope the example makes it easier to understand.
I am using a component to render it.
I guess using regex would be the easiest way to do this, but still it would be great if people can point me out to references/examples to get this done with ease.
I am using flex 4.5.
Thanks,
Neeraj
You can use String.replace method to do the job, it's possible to use both string or regular expressions to match some part of a string value. So regarding to your question the code will look like below:
var filter: String = "My name is blah\r\r\r blah \n\n\n\r\nMy name is blah\r\n\r\r\n\n\n\r\n";
filter = filter.replace(/(\r|\n)+/g, "\n");
multiple contiguous new line/line feed characters
If you mean sequence "\r\n" then:
var myString:String = "text\r\ntext\r\ntext\r\n";
myString = myString.split("\r").join("\n").split("\n\n").join("\n");

Using PIG with Hadoop, how do I regex match parts of text with an unknown number of groups?

I'm using Amazon's elastic map reduce.
I have log files that look something like this
random text foo="1" more random text foo="2"
more text notamatch="5" noise foo="1"
blah blah blah foo="1" blah blah foo="3" blah blah foo="4" ...
How can I write a pig expression to pick out all the numbers in the 'foo' expressions?
I prefer tuples that look something like this:
(1,2)
(1)
(1,3,4)
I've tried the following:
TUPLES = foreach LINES generate FLATTEN(EXTRACT(line,'foo="([0-9]+)"'));
But this yields only the first match in each line:
(1)
(1)
(1)
You could use STRSPLIT: http://pig.apache.org/docs/r0.8.0/piglatin_ref2.html#STRSPLIT
The regex to split on would be [^0-9]+ (i.e., not numbers)
This will effectively split on large portions of non-numbers, leaving only tokens of numerical digits.
Another option would be to write a Pig UDF.
REGEX_EXTRACT function may help you to get your desired output
REGEX_EXTRACT(input, 'foo=(.*)',2) AS input;