Alexxander Posted November 25, 2013 Posted November 25, 2013 (edited) Hi all i have a big amount of text files that is link this {3} Ceux qui comparent leurs femmes au dos de leurs mères, puis reviennent sur ce qu’ils ont dit, doivent affranchir un esclave avant d’avoir aucun contact [conjugal] avec leur femme. C’est ce dont on vous exhorte. Et Allah est Parfaitement Connaisseur de ce que vous faites. {4} Mais celui qui n’en trouve pas les moyens doit jeûner alors deux mois consécutifs avant d’avoir aucun contact [conjugal] avec sa femme. Mais s’il ne peut le faire non plus, alors qu’il nourrisse soixante pauvres. Cela, pour que vous croyiez en Allah et en Son messager. Voilà les limites imposées par Allah. Et les mécréants auront un châtiment douloureux. i want it to cut each part alone and the separator is bracket then number then bracket {NUM} so the first one must be {3} Ceux qui comparent leurs femmes au dos de leurs mères, puis reviennent sur ce qu’ils ont dit, doivent affranchir un esclave avant d’avoir aucun contact [conjugal] avec leur femme. C’est ce dont on vous exhorte. Et Allah est Parfaitement Connaisseur de ce que vous faites. i tried this #include <Array.au3> $sString=ClipGet() $sResult=StringRegExpReplace($sString,"(\{\d{1,}\})",@CR & "$1") $sResult=StringRegExpReplace($sResult,"(\r)(.*)","$2",1) ;If you want it in an array add this: $array=StringSplit($sResult,@CR) $var = 1 For $i = 1 To $array[0] FileWrite(@DesktopDir & "\sura\" & $var & ".txt" , $array[$i] & @CRLF) $var = $var + 1 Next it is cutting the text when it see the {NUM} but it is also cutting it when it see a new line i want it to complete the sentence even if it is on 2 lines any ideas ? Edited November 25, 2013 by Alexxander
Terenz Posted November 25, 2013 Posted November 25, 2013 (edited) You can't use _StringBetween? I have missunderstood See if this is useful: #include <Array.au3> $sString = ClipGet() $aDelim = StringRegExp($sString, "{.}", 3) $aParts = StringSplit(StringRegExpReplace($sString, "{.}", "*|*"), "*|*", 3) For $i = 0 To UBound($aDelim) - 1 $aParts[$i + 1] = $aDelim[$i] & $aParts[$i + 1] Next $aParts[0] = UBound($aDelim) _ArrayDisplay($aParts) Edited November 25, 2013 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
mikell Posted November 25, 2013 Posted November 25, 2013 (edited) This should do the work : #include <Array.au3> $sString = ClipGet() $aResult = StringRegExp($sString,'(?s){([^{]+)', 3) For $i = 0 to UBound($aResult)-1 $n = StringRegExpReplace($aResult[$i], '(?s)(^\d+).+', "$1") $txt = StringReplace(StringRegExpReplace($aResult[$i], '(^\d+}\s*)', ""), @crlf, " ") FileWrite(@DesktopDir & "\sura " & $n & ".txt" , $txt & @CRLF) Next Edited November 25, 2013 by mikell
kylomas Posted November 25, 2013 Posted November 25, 2013 Terenz, Another alternative... #include <array.au3> #include <file.au3> local $str = fileread(@scriptdir & '\' & 'test10.txt') local $array = stringregexp($str,'(?m)\{[^\{]+',3) ; include curly braces ;local $array = stringregexp($str,'(?m)\} ([^\{]+)',3) ; exclude curly braces _FileWriteFromArray(@scriptdir & '\test010_out.txt',$array) shellexecute(@scriptdir & '\test010_out.txt') kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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