Deye Posted January 1, 2020 Share Posted January 1, 2020 (edited) Been trying this for a while now @Getting lines between 3. To protect .*\n <(.*)>|8. Do not delete Not sure what else to try .. $str = 'This list is non-exhaustive - the Moderating team reserve the right to close any thread that they fe' _ & 'el is contrary to the ethos of the forum.' & @LF & @CRLF $str &= '2. Do not post material that could be considered pornographic, violent or explicit - or express pers' _ & 'onal opinions that would not be acceptable in a civilized society. Do not post any copyrighted mater' _ & 'ial unless the copyright is owned by you or by this site.' & @LF & @CRLF $str &= '3. To protect this community, any files posted by you are subject to checks to ensure that they do n' _ & 'ot contain malware. This includes, but is not limited to, decompilation and reverse engineering.' & @LF & @CRLF $str &= '4. Do not flame or insult other members - and just report the thread to a Moderator (see below) if y' _ & 'ou are so attacked.' & @LF & @CRLF $str &= '5. Do not PM other users asking for support - that is why the forum exists, so post there instead.' & @LF & @CRLF $str &= '6. Do not create multiple accounts - if you inadvertently created multiple accounts then contact a M' _ & 'oderator to close the unwanted ones.' & @LF & @CRLF $str &= '7. Do not repost the same question if the previous thread has been locked - particularly if you mere' _ & 'ly reword the question to get around one of the prohibitions listed above.' & @LF & @CRLF $str &= '8. Do not delete your posts, nor completely remove their content, if doing so will interrupt the flo' _ & 'w of the thread.' & @LF & @CRLF $str &= '9. Do not post in a thread while the Moderating team are actively trying to determine whether it is ' _ & 'legal.' & @LF & @CRLF $str &= 'The Moderation team will do their best to act in fair and reasonable manner. Sanctions will only be ' _ & 'applied as a last resort and any action taken will be explained in the relevant thread.' & @LF & @CRLF $str &= 'If moderation action is taken, you will need to acknowledge this through a dialog or you will be una' _ & 'ble to post further in the forum. Please note that this dialog is not an agreement that the warning ' _ & 'was justified - it is only there so that members are aware that moderation action has been taken and' _ & ' that they may have certain restrictions applied to their account.' & @LF & @CRLF $str &= 'If you feel that you have been unfairly moderated then contact the Moderator concerned - using a PM ' _ & 'or the "Report" button is preferable to opening a new thread (although new members may have to do th' _ & 'is). But do be aware that the Moderation team has the final word - the rules are set out by the site' _ & ' owner and you are only welcome here if you respect his wishes.' $sOutput = StringRegExpReplace($str, "(.)(\Q3. To protect\E.*\n\Q8. Do not delete\E)", "$2") MsgBox("","", $sOutput) Thanks Edited January 1, 2020 by Deye Link to comment Share on other sites More sharing options...
Nine Posted January 1, 2020 Share Posted January 1, 2020 Maybe this ? Local $array = StringRegExp ($str, "(?m)^([3-8].*)$", 3) _ArrayDisplay ($array) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
TheXman Posted January 1, 2020 Share Posted January 1, 2020 Or if you want to stick with StringRegExpReplace, this is one way that'll work: $sOutput = StringRegExpReplace($str, "(?sm).*(^3[.].*^8[.].*?$).*", "\1") It's not pretty, but it will work. Deye 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Deye Posted January 1, 2020 Author Share Posted January 1, 2020 (edited) I need to start with any unique string in a line @ skipping that line going to next unique string in some other line delimiting it and get what's between those two string mentioned lines Not there yet: MsgBox("", "", _between("protect", "If moderation action")) Func _between($s1, $s2) Return StringStripWS(StringRegExpReplace($str, ".*\n\R(.*\Q" & $s1 & "\E.*)|(.*\Q" & $s2 & "\E.*\W\R.*)", ""), 3) EndFunc ;==>_between Edited January 1, 2020 by Deye Link to comment Share on other sites More sharing options...
TheXman Posted January 1, 2020 Share Posted January 1, 2020 (edited) Or create your own user-defined function (or should I say use something like my example below) . Everything doesn't have to be a regular expression. Spoiler expandcollapse popup#include <Constants.au3> $str = 'This list is non-exhaustive - the Moderating team reserve the right to close any thread that they fe' _ & 'el is contrary to the ethos of the forum.' & @LF & @CRLF $str &= '2. Do not post material that could be considered pornographic, violent or explicit - or express pers' _ & 'onal opinions that would not be acceptable in a civilized society. Do not post any copyrighted mater' _ & 'ial unless the copyright is owned by you or by this site.' & @LF & @CRLF $str &= '3. To protect this community, any files posted by you are subject to checks to ensure that they do n' _ & 'ot contain malware. This includes, but is not limited to, decompilation and reverse engineering.' & @LF & @CRLF $str &= '4. Do not flame or insult other members - and just report the thread to a Moderator (see below) if y' _ & 'ou are so attacked.' & @LF & @CRLF $str &= '5. Do not PM other users asking for support - that is why the forum exists, so post there instead.' & @LF & @CRLF $str &= '6. Do not create multiple accounts - if you inadvertently created multiple accounts then contact a M' _ & 'oderator to close the unwanted ones.' & @LF & @CRLF $str &= '7. Do not repost the same question if the previous thread has been locked - particularly if you mere' _ & 'ly reword the question to get around one of the prohibitions listed above.' & @LF & @CRLF $str &= '8. Do not delete your posts, nor completely remove their content, if doing so will interrupt the flo' _ & 'w of the thread.' & @LF & @CRLF $str &= '9. Do not post in a thread while the Moderating team are actively trying to determine whether it is ' _ & 'legal.' & @LF & @CRLF $str &= 'The Moderation team will do their best to act in fair and reasonable manner. Sanctions will only be ' _ & 'applied as a last resort and any action taken will be explained in the relevant thread.' & @LF & @CRLF $str &= 'If moderation action is taken, you will need to acknowledge this through a dialog or you will be una' _ & 'ble to post further in the forum. Please note that this dialog is not an agreement that the warning ' _ & 'was justified - it is only there so that members are aware that moderation action has been taken and' _ & ' that they may have certain restrictions applied to their account.' & @LF & @CRLF $str &= 'If you feel that you have been unfairly moderated then contact the Moderator concerned - using a PM ' _ & 'or the "Report" button is preferable to opening a new thread (although new members may have to do th' _ & 'is). But do be aware that the Moderation team has the final word - the rules are set out by the site' _ & ' owner and you are only welcome here if you respect his wishes.' MsgBox("","", extract_lines("protect", "posts")) Func extract_lines($sStart, $sEnd) Local $aLinesIn[0] Local $sOutput = "" Local $iCurrentLine = 0 ;Split lines into an arry $aLinesIn = StringSplit($str, @CRLF, $STR_ENTIRESPLIT) ;Spin thru lines in For $i = 0 To UBound($aLinesIn) - 1 ;If starting string found If StringInStr($aLinesIn[$i], $sStart) Then ;Start outputting lines until end of array or ending string found $iCurrentLine = $i While $iCurrentLine < UBound($aLinesIn) $sOutput &= $aLinesIn[$iCurrentLine] If StringInStr($aLinesIn[$iCurrentLine], $sEnd) Then ExitLoop 2 $iCurrentLine += 1 WEnd EndIf Next Return $sOutput EndFunc Edited January 2, 2020 by TheXman Nine and Deye 2 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Nine Posted January 2, 2020 Share Posted January 2, 2020 7 minutes ago, TheXman said: Everything doesn't have to be a regular expression. Well, it seems that it is the trendy solution right now.... Deye and TheXman 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Deye Posted January 2, 2020 Author Share Posted January 2, 2020 LOL Link to comment Share on other sites More sharing options...
Solution mikell Posted January 2, 2020 Solution Share Posted January 2, 2020 (edited) 9 hours ago, TheXman said: Everything doesn't have to be a regular expression. Yes... though RE can be useful sometimes expandcollapse popup$str = 'This list is non-exhaustive - the Moderating team reserve the right to close any thread that they fe' _ & 'el is contrary to the ethos of the forum.' & @LF & @CRLF $str &= '2. Do not post material that could be considered pornographic, violent or explicit - or express pers' _ & 'onal opinions that would not be acceptable in a civilized society. Do not post any copyrighted mater' _ & 'ial unless the copyright is owned by you or by this site.' & @LF & @CRLF $str &= '3. To protect this community, any files posted by you are subject to checks to ensure that they do n' _ & 'ot contain malware. This includes, but is not limited to, decompilation and reverse engineering.' & @LF & @CRLF $str &= '4. Do not flame or insult other members - and just report the thread to a Moderator (see below) if y' _ & 'ou are so attacked.' & @LF & @CRLF $str &= '5. Do not PM other users asking for support - that is why the forum exists, so post there instead.' & @LF & @CRLF $str &= '6. Do not create multiple accounts - if you inadvertently created multiple accounts then contact a M' _ & 'oderator to close the unwanted ones.' & @LF & @CRLF $str &= '7. Do not repost the same question if the previous thread has been locked - particularly if you mere' _ & 'ly reword the question to get around one of the prohibitions listed above.' & @LF & @CRLF $str &= '8. Do not delete your posts, nor completely remove their content, if doing so will interrupt the flo' _ & 'w of the thread.' & @LF & @CRLF $str &= '9. Do not post in a thread while the Moderating team are actively trying to determine whether it is ' _ & 'legal.' & @LF & @CRLF $str &= 'The Moderation team will do their best to act in fair and reasonable manner. Sanctions will only be ' _ & 'applied as a last resort and any action taken will be explained in the relevant thread.' & @LF & @CRLF $str &= 'If moderation action is taken, you will need to acknowledge this through a dialog or you will be una' _ & 'ble to post further in the forum. Please note that this dialog is not an agreement that the warning ' _ & 'was justified - it is only there so that members are aware that moderation action has been taken and' _ & ' that they may have certain restrictions applied to their account.' & @LF & @CRLF $str &= 'If you feel that you have been unfairly moderated then contact the Moderator concerned - using a PM ' _ & 'or the "Report" button is preferable to opening a new thread (although new members may have to do th' _ & 'is). But do be aware that the Moderation team has the final word - the rules are set out by the site' _ & ' owner and you are only welcome here if you respect his wishes.' ;MsgBox(0,"", extract_lines($str, "protect", "posts")) ;MsgBox(0,"", extract_lines($str, "non-exhaustive", "ethos")) ;MsgBox(0,"", extract_lines($str, "protect", "")) ;MsgBox(0,"", extract_lines($str, "", "posts")) MsgBox(0,"", extract_lines($str, "protect", "?")) Func extract_lines($txt, $sStart, $sEnd) Return StringRegExpReplace($txt, '(?s)(?:^|.*\R)(\N*?' & $sStart & '.*' & $sEnd & '\N*).*', "$1") EndFunc Edited January 2, 2020 by mikell Tiny modif to make the srer more versatile :) Deye 1 Link to comment Share on other sites More sharing options...
Deye Posted January 2, 2020 Author Share Posted January 2, 2020 (edited) Nice tap Edited January 2, 2020 by Deye Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now