Remove all but specific phrase/line containing changing value.
-
Hi, I am trying to find all the database index values from a websites source code and delete all other text/code in the document so I am only left with the values.
Here is the data I currently have (“before” data):
[wall of code]
data-index="1034823\
[wall of code]
data-index="1031769\
[wall of code]
data-index="1030975\
[wall of code]
data-index="1028228\Here is how I would like that data to look (“after” data):
10348231031769
1030975
1028228
I am kind of new to notepad++ and I couldn’t get my head to wrap around this one. I would appreciate the help!
-
Try:
Find:
(?s).*?data-index="(\d+)\\
Replace:${1}\r\n\r\n
Search mode: Regular expressionHave your caret at top-of-file and press the Replace All button.
-
Hi, i tried this but instead of giving just the values it deleted all of the text. Could this be because all of the code is on a single line? The code only appears to be in a single line in Notepad++, not other text editors.
-
Hello, @jrdn-bautista,
When you start a new post, preferably click on the
< / >button, on top of the posting window and replace the selectedcode_textzone with your present text. this will encapsulate all your text in a grey box which prevents the posting engine from possibly altering the text as it tries to format the post !Best Regards,
guy038
-
@jrdn-bautista said in Remove all but specific phrase/line containing changing value.:
Hi, i tried this but instead of giving just the values it deleted all of the text. Could this be because all of the code is on a single line?
If I put all of your “before” text on a single line, what I provided still works just fine, for me.
Suggest you follow the FAQ for posting questions such as yours, in order to adequately convey all circumstances of your problem.
-
Here is the raw code if anyone is willing to take a look, would really appreciate it:
pastebin com/JkEyygEV
-
Hi, @jrdn-bautista, @alan-kilborn and All,
You should have posted your text like that :
[wall of code] data-index=\"1034823\" [wall of code] data-index=\"1031769\" [wall of code] data-index=\"1030975\" [wall of code] data-index=\"1028228\"
Thus, :
-
Move on top of your file
-
Open the Replace dialog (
Ctrl + H)
The search regex S/R becomes :
-
SEARCH
(?s-i).*?data-index=\\"(\d+)\\" -
REPLACE
${1}\r\n\r\n -
Search mode =
Regular expression -
Click on the
Replace Allbutton
Here you are !
BR
guy038
-
-
This worked! Sorry for the mistype, I just pasted directly from the code and I didn’t know what to edit to make it work correctly. Thank you!!
-
@jrdn-bautista said in Remove all but specific phrase/line containing changing value.:
I just pasted directly from the code and I didn’t know what to edit to make it work correctly
This is why we have that FAQ entry.
-
This post is deleted!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login