Notepad++ find and replace after specific character [closed] - replace

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have hundred of song lyric database files, and I need to do something like this,
from this :
PPK4: B'rilah Hormat Pada Hu
Judul Inggris: Glory to God in the Highest
Lagu: unknown Syair: unknown
1=A, 4/4
to become like this :
PPK4: B'rilah Hormat Pada Hu
B'rilah Hormat Pada Hu
Judul Inggris: Glory to God in the Highest
Lagu: unknown Syair: unknown
1=A, 4/4
PPK4 is a song number. so, there will be like PPK1 until PPK255, KPPK1 .. KPPK300 etc.
and same format, "#songcode" ":" "(space)" "song title" "CRLF"
How do I do it using Find and Replace?

The answer involves regular expressions.
You could try "([A-Z]+[0-9]+[:])(.*)"
This will capture the song number as group 1 and the song title as group 2. You can then replace this with "\1\2\n\2", i.e. group 1 followed by group 2, a newline and group 2 again.

Related

Conditional Regex for Percentage based values [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
I've never been very good at regex, but I really need to grab the percentage information from these log entries; however, the warn/critical message moves around depending on where the warning was located in either the In or the Out utilization. I just can't figure out the regex. Here are two example entries that show both in and out issues:
["XXXXXXX"], (up), MAC: XX:XX:XX:XX:XX:XX, Speed: 2 GBit/s, In: 0 Bit/s (0%), Out: 6.53 GBit/s (warn/crit at 1.6 GBit/s/1.8 GBit/s) (326.45%)(!!)
["XXXXXXX"], (up), MAC: XX:XX:XX:XX:XX:XX, Speed: 2 GBit/s, In: 0 Bit/s (warn/crit at 1.6 GBit/s/1.8 GBit/s) (95.45%), Out: 6.53 GBit/s (32.00%)(!!)
Ultimately I need to use capture groups to capture both the in and out utilization percentage. But every regex I try only finds a single percentage. Help on this would be greatly appreciated. Thanks in advance.
EDIT SHOWING EXPECTED RESULT:
for each line the regex capture groups would identify in and out so the program can see both the in and out utilization. The program is expecting a key value pair from every log entry like the following:
IN:0% OUT:326.45%
IN:95.45% OUT:32.00%
Do you need something like this?
In:.+\(([0-9\.]+%)\).+Out:.+\(([0-9\.]+%)
If you just need to pull out values with percentage information, then it can help
https://regex101.com/r/B9pZeO/1

How to avoid unrelated data from postgresql search [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to get the data to contain keyword of both "LED" and "car"
select count ( * ) from test_eu where eng_discription ~ '.* led .* AND .* car .*';
When I search PostgreSQL with the above code, results include those unrelated data like
so-called cardboard
carefully installed
In order to avoid this, I thought both sides of the searching keyword contain space " " solve this problem.
regex of space is
\s
so I made this code
select count ( * ) from test_eu where eng_discription ~ '\sled\s and \scar\s';
but still does not work.
How should I modify my code?
Assuming you want to check for the presence of both LED and car, anywhere in the description column, you could try:
SELECT COUNT(*) AS cnt
FROM test_eu
WHERE eng_discription ~* '\yled\y' AND eng_discription ~* '\ycar\y';

Replace the words "can't, don't" by "can not, do not" using python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need to replace words like "{can't, don't, won't }" by "{can not, do not, would not}" using python
The problem is:
"can't" can be detected by checking suffix "n't", so we can replace "n't" by "not"
But how can we transform "ca" to "can" as when we split "can't" it should be transformed to "can not"?
Since the rules of English are large and sometimes inconsistent, your best bet is probably just to set up full word maps rather than trying to figure out on the fly which letters are represented by the apostrophe.
In other words, a dictionary with values like:
can't -> can not
don't -> do not
won't -> will not
:
oughtn't -> ought not

Place Commas Between Numbers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I'm having trouble getting this to work in AS3, I want to place a comma between numbers only when their is a whitespace.
For example, if the string is "1.23 5.34" I want it to become "1.23, 5.34". The trouble is the white space varies and the number may or may not contain a decimal. So, I'd want "1 1.4" to become "1, 1.4" or "2.3 4.5" to become "2.3, 4.5". This also includes negative numbers, so "1.4 -15.3" should become "1.4, -15.3". If there is anything but a number on either side of the white space, I'd want to skip that space and not effect it. So "Car 35.2" would be skipped and so would (13.5 ).
I've tried several Regexs found around the net and did my best with the limited regex knowledge I have, any help would be greatly appreciated.
Thanks.
UPDADE
(?<=\d)(\s)(?=-?\d) (thanks for your comment Tim)
Try the folowing pattern:
"(?<=\d)(\s)(?=[\d-])" (edited to include negative ones)
replace for ",$1"
youre essentially replacing " " with ", "
var value:String = "1 2 -3 4 -5";
var csvValue:String = value.split(" ").join(", "); // will print out "1, 2, -3, 4, -5"

Recognizing patterns given a set of sentences [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a text file with lots of sentences. These sentences can occur in patterns. How do I recognize these patterns?
For example:
i woke up in the morning
i went to school
i played football
i came back home
i woke up in the morning
i went to school
i played basketball
At this point I want the program to say that "I played football" should have appeared.
This task seems to little bit complicate,but you can try this simple code for understanding or if finds it useful you can further implement it::
//the sentences/input input String
String sampleString1="xyz";
String[] sampleString2=sampleString1.split(".");
for(int i=1;i<=sampleString2.length;i++){
//The pattern which you can specify to match with the sentence
if(sampleString2[i].substring(0, 14).equals(sampleString2[0].substring(0,16))){
//code to execute the matched sentence.
System.out.println("Sentence matching with pattern ::" + sampleString2[i]);
}
}
If the pattern to be matched is the first line of the sequence ,then try this code.