How to return values against a certain Parameter
-
Hi… I would like your support in getting output in a certain pattern for example, after i do a batch query on my system, The output is as below (AS-IS)
File Number: 886-1123456
A: Male
B: Active
C: Green
D: 45
E: ApplicableFile Number: 886-11245663
A: Female
B: Active
C: Red
D: 42
E: ApplicableFile Number: 886-33225571
A: Male
B: Not Active
C: Yello
D: 43
E: Not Applicablei want certain parameters only for later analysis and I want to extract the output in below format : (TO-BE)
File Number: 886-1123456
A: Male
File Number: 886-11245663
A: Female
File Number: 886-33225571
A: MaleI have a script in ULTRAEDIT for egs “^{FILE Number=^}^{A =^}” this returns only the File Number and its value AND A Parameter and its value. how to get a script for the same in notepad++
Thanks in advance
-
@Annin-Jacob said in How to return values against a certain Parameter:
i want certain parameters only for later analysis and I want to extract the output in below format
It seems fairly simple. Using the Replace function we have
Find What:(?-s)^(file number.+\R.+\R)(.+\R){4}\R*
Replace With:\1
This is a regular expression so have the search mode set to “regular expression”. You can click on “Replace” if wanting to check each record being replaced, or “Replace All” if wanting to do the entire file in 1 go. Best to have the cursor in the first position of the file as it’s dealing with a set of lines together,There must be a single empty/blank line at the bottom of the file for this to process the last record set. It also presumes all record sets have the same order: A:, B:, C:, D:, E:. In my test there was a last line left which is blank, you may want to check that.
Let me know either way, we do like feedback. If an issues ask.
-
Hi Thanks for the feedback.
i am not clear in the script mentioned.for egs, for the mentioned output i have shown, how would you modify your given script ?
can you show me the values you would put in your script to return “FIle Number” and “A” ? -
@Annin-Jacob said in How to return values against a certain Parameter:
Hi Thanks for the feedback.
i am not clear in the script mentioned.Do you know what a regular expression is? That is what my solution is.
Have you tried my solution in the Replace function? I doubt it as if you had you would see it returns exactly what you requested.If I’m misunderstanding what your problem is you need to explain better. Currently I believe you have some record sets with a File Number on the first line, followed by lines A,B,C,D and E with data. You ONLY want the file number line and the A line.
Terry
-
Dear Terry -
Thanks for the feedback
Yes i am aware of what regular expression is.No, the script didnt work. i did try it…
i was able to get the result with the below though^.+File Number =|^.+D=
Issue resolved.
Thanks -
^.+File Number =|^.+D=
Issue resolved.I am glad you got it working.
However, there were no equal signs
=
in the example data you gave us, so it is impossible for the regular expression to have worked with the data you gave us. Either the data you gave us doesn’t match the data you used it on, or you have not given us the actual regular expression that really worked for you, or the forum has badly mangled one or both because you didn’t use the</>
button in the forum to format your data and regex. In any of those cases, it would have been impossible for us to properly help you.I make this post, not because I expect @Annin-Jacob to ever come back and read any more here – though if they do, I hope they learn from this advice – but because I am hoping that other people who read this site will take this advice as an example of why it’s so important to give reasonable example data, and to use the formatting available in the forum to make sure to properly display the example text exactly as it’s pasted in.
----
Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as plain text using the
</>
toolbar button or manual Markdown syntax. Screenshots can be pasted from the clipboard to your post usingCtrl+V
to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get… Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.