Notepad++ RegEx - regex

I am in need a reg ex for the following:
/****** Object: AnyNumberofCharacters ******/
Here is what I have Tried but I cant make it work
/^\/\*\*\*\*\*\* Object\:.*\*\*\*\*\*\*\//
Could someone tell me what I'm doing wrong?
Edited: Sorry I'm using NotePad++ to search a number of text files for this string.

Since you are using Notepad++ to find that string, you don't need the delimiters. And therefore, you don't need to escape the forward slashes either.
^/\*\*\*\*\*\* Object\:.*\*\*\*\*\*\*/

I guess that
/^\/\*{6} Object: [\w]+ \*{6}\/$/
should do that...
Don't forget to adjust the [\w] range accordingly.

Related

Nino Regular Expression

I have the following text, for example:
nino&searchPhrase=jn123456&alphabetical
And I want to extract jn123456.
I've put together the following regex to extract NINOs:
(\bnino?\b.*?|Nino?\b.*?)[a-zA-Z]{2}[0-9]{6}
The problem I have is at the very end of the regex where I'm matching the last alpha character which may or may not be there.
I've tried adding the following at the end of the regex shown above without any luck:
?[a-zA-Z]{1} and
[?a-zA-Z]{1}
Could someone please look at this and let me know where I've gone wrong.
Many thanks and kind regards
Chris
You may use something like this:
^[Nn]ino&?\w*=([a-z]{2}\d{6})
which will capture "jn123456" in the first capturing group.
Demo.
If the character & can be anything else, then you may use . instead.

Replace all commas within a string with the first word of that string?

Is there a way to capture the first word of a string and then replace all commas using the captured first word?
I have attempted a hundred ways without success. I must be missing something. Is there a simple way to set a variable with regex?
string example:
"somename",'2','3','4','11','22','33','44','etc...'
desired results:
"somename",'2'
"somename",'3'
"somename",'4'
"somename",'11'
"somename",'22'
"somename",'33'
"somename",'44'
"somename",'etc...'
I'm using notepad++ (v7.5.6) for this. Any help would be greatly appreciated.
An interesting problem... the best I could come up with inside notepad++ was this: Find ^([^,]+)(,.+)(,[^,]+)$, replace with \1\2\n\1\3. This will replace
"somename",'2','3','4','11','22','33','44','etc...'
with
"somename",'2','3','4','11','22','33','44'
"somename",'etc...'
Continual pressing of Replace will eventually give you the desired output.
Hopefully someone else can do better...

Find and replace in notepad for large file++

I have an XML file that has 9000 lines in it.
Each XML node has about 10 attributes in it.
One of the attributes is:
<CreatedDate>2009-10-26T02:39:24</CreatedDate>
What I need to do is change the format of the DateTime to:
<CreatedDate>27/05/2010 07:30:16</CreatedDate>
But I do not know how to do it.
I know I could write a Regex to identify each value that needs to be replaced, but how can make it only change the values I want and maintain the rest?
I have thought about writing a macro, but the document is too big to format in a way that I could predict where the element I want ot change is, and searching for something does not seem to work on a macro.
Any ideas? - I am sure it can be done.
If you want to change datetimes format only inside <CreatedDate> tags, try the regex replace in Notepad++ like this:
Replace this:
<CreatedDate>(\d{4})\-(\d{2})\-(\d{2})T([\d\:]*)</CreatedDate>
With this:
<CreatedDate>$3/$2/$1 $4</CreatedDate>
We refer to each parentheses using a $ symbol and it's position, so we can use those values in the replacing result.
Find:
<CreatedDate>(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)</CreatedDate>
Replace:
<CreatedDate>\3/\2/\1 \4:\5:\6</CreatedDate>
\d matches a Digit.
And the braces create a group that you reference with e.g. \1
Find this
<CreatedDate>(\d{4})-(\d{2})-(\d{2})T(\d{2}:\d{2}:\d{2})<\/CreatedDate>
Replace with:
<CreatedDate>\3/\2/\1 \4<\/CreatedDate>

regular expression in excel for numbers before a slash

In the example below, I need to change everything before the final slash to jreviews/
so in the example below the first line would become
jreviews/159256_0907131531001639107_std.jpg
i am using open office find and replace tool, I see there is an option for regex but i dont know how to do this. How can I find and replace the img.agoda urls and everything thats a number and slash, and replace that with jreviews/ ?
but keeping the numbers after that final slash, because these are the filename.
http://img.agoda.net/hotelimages/159/159256/159256_0907131531001639107_std.jpg
http://img.agoda.net/hotelimages/161/161941/161941_1001051215002307125_std.jpg
http://img.agoda.net/hotelimages/288/288595/288595_111017161615_std.jpg
http://img.agoda.net/hotelimages/289/289890/289890_13081511070014319856_std.jpg
http://img.agoda.net/hotelimages/305/305075/305075_120427175058_std.jpg
http://img.agoda.net/hotelimages/305/305078/305078_120427175537_std.jpg
Regex seems like overkill, at least for your examples. Since they all have the same number of subfolders, a simple Find and Replace with wildcards works for me. Here's how I did it in Excel:
Just replace http://*/*/*/*/ with jreviews/.
Try this:
Replace the below match with "CustomName/"
^.+[/$]

Regex to match surrounding text

I need to replace "something[anything]" with "somethingElse(anything)", the tricky part is anything could be anything, and I don't want to replace that. Is it possible to do with regex?
P.S. In real scenario I'd be using PHPStorm to look / replace it. It would help me a lot to show me what to put exactly at the find window.
Thank you!
Idea: Capture 'anything' in a capturing group in regex. Then, back reference it in the replacement.
For example: search for something[([^]]*)\] and replace with somethingElse($1).