Notepad ++ : Regular expression to join multiple lines in single line [duplicate] - regex

This question already has an answer here:
Notepad++ : Insert blank new line after match of some string
(1 answer)
Closed 4 years ago.
I have to join lines to make questions (having serial no. in order 1,2,3....) in one line and all options as shown below in another single line ? Example :
1.For his alleged
involvements in
espio-nage
(1) abc
(2) saf
(3) asf
(4) aqg
Output should be:
1. For his alleged involvement in espio-nage...
(1)abc (2)saf (3)asf (4)aqg
Note:I just want to make it compact to read in kindle reader so that maximum space will get utilised

I think
\r?\n(?!\(1|\d)
(And replace with empty string) will do what you want
Explanation: Looks for a newline that's not followed by either (1 or a single digit.
If you ever have more than 9 options that will cause problems as it'll split before (10 (11 etc. - in which case \r?\n(?!\(1\)|\d) should do it

Select text/elements and press CTRL+J

Related

How can I extract file extension from string? [duplicate]

This question already has answers here:
How to use regex to get file extension?
(3 answers)
Closed 6 months ago.
We have a custom field defined in data studio which extracts and returns the file extension from a string in this case it is from the event label.
I have been using the below with some success
REGEXP_EXTRACT(Event Label, '\\.([\\w\\.-]+)$')
However I'm finding if the string contains multiple periods its including that aswell
Eg it's also extracting text like
07.21.pdf
7.22.PDF
07.21.docx
docx.pdf
How can I tweak my regex to only include from the last period and ignore any earlier.
You could try replacing [\\w\\.-] with [^\\.]
\\.([^\\.]+)$
[^\\.] will match everything except for ., so the match will not be able to contain dots inside.
The full formula would look like this:
REGEXP_EXTRACT(Event Label, '\\.([^\\.]+)$')

How to use awk to find a pattern, then move down a certain number of lines, and print? [duplicate]

This question already has answers here:
Printing with sed or awk a line following a matching pattern
(9 answers)
Extract Nth line after matching pattern
(3 answers)
Closed 2 years ago.
I am trying to use awk to find a pattern, then print the line X amount of lines below it.
For example:
This a line of something I dont need
More of what I dont need
This is what I want to print # <-- This contains the same information of what I want to print, but I do not want to print this line.
This is the pattern I need to find
This is unimportant
So is this
This too
As well as this
This is what I want to print # <-- This is the line I actually want to print
Notice how the same thing I want to print comes up multiple times, which is why I need to only print it when it comes after the pattern I define. So, theoretically, I would put the afformentioned text into awk and get:
This is what I want to print # <-- This is the line I actually want to print
That is occurrence of This is what I want to print after the pattern I defined.
I don't really know what I'm doing when comes to regex and awk, so I don't even know if this is possible. If it is not possible with these tools, then is there a way to do this at all?
PS:
I am using this in a script that gives information about one of my audio sinks. There are many sinks, that all have the same information fields. So, I am searching for the sink I want, then printing a certain field which comes after the name of the sink. I hope this makes sense.

Fortran string formatting issues [duplicate]

This question already has answers here:
invalid character name at (1)
(2 answers)
Compilation error: Invalid character in name at (1)
(1 answer)
Closed 3 years ago.
I'm having some issues coding in fortran for a school assignment. I'm trying to write a sentence all on one line (per request of the instructor), but I'm having format issues.
From my understanding I need to use the & to concat the two lines (see below)
I've tried multiple variants of this but I'm having no luck.
'''[j87n896#csci305 fortran]$ gfortran money.f -o money
money.f:94:67:
94 | write(*,*) lunks,'lunkers',loons,'loonters',lits,'littles' &
| 1:
95 | & poons, 'pooneys'
| 1
Error: Invalid character in name at (1)'''
In case you are coding in fixed form - and I believe you are - line continuation is done by adding any non-zero and non-blank character in the sixth column of the second line:
write(*,*) lunks,'lunkers',loons,'loonters',lits,'littles',
+ poons, 'pooneys'
In the case above, I have used a +, but any non-zero/blank char in the 6th column of the second line will do it. You can also extend it to split into more lines by adding chars at the 6th column of the third line, fourth line and so on.
In case you are coding in free form, the continuation is done by adding a & in the end of the first line and in the beginning of the next line (although this last one is not always required):
write(*,*) lunks,'lunkers',loons,'loonters',lits,'littles', &
& poons, 'pooneys'
You may benefit from reading this unofficial copy of the Fortran Standard. Item 6.3.2.4 describes continuation in free format, while item 6.3.3.3 describes continuation in fixed format (which I believe to be your case). You should not expect to understand every single thing you read there, but the sooner you start to try, the sooner it will make some sense for you.
Also, in your example there is a comma missing right after 'littles'. I've fixed that in both examples. Check it out.

Regex extract number from a string with a specific pattern in Alteryx [duplicate]

This question already has answers here:
Find numbers after specific text in a string with RegEx
(3 answers)
Closed 3 years ago.
I have string like this which looks like a url
mainpath/path2/abc/PI 6/j
From the string I need to get the number along with PI
Main problem is the position of PI part wont be always the same. Sometimes it could be at the end. Sometimes at the middle.
So how can I get that number extracted using regex?
I'm really stucked with this
It's as simple as using the RegEx Tool. A Regular Expression of /PI (\d+) and the Output Method of "Parse" should do the trick.
If you're using Alteryx... suppose your field name is [s] and you're looking for [f] (in your example the value of [f] is "PI")... then you could have a Formula tool that first finds /PI by first creating a new field [tmp] as:
SubString([s],FindString([s],"/"+[f])+1)
and then creating the field you're after [target]:
SubString([tmp],0,FindString([tmp],"/"))
From there run [target] through a "Text to Columns" tool to split on the space, which will give you "PI" and "6".

detecting word boundary with regex in data frame in R [duplicate]

This question already has answers here:
Using regex in R to find strings as whole words (but not strings as part of words)
(2 answers)
Closed 4 months ago.
I have a data.frame named all that has a column of factors, these factors include "word","nonword" and some others. My goal is to select only the rows that have the factor value "word".
My solution grep("\bword\b",all[,5]) returns nothing.
How come word boundaries are not recognized?
In R, you need two times \:
grep("\\bword\\b", all[5])
Alternative solutions:
grep("^word$", all[5])
which(all[5] == "word")