maxilla Posted March 14, 2007 Posted March 14, 2007 (edited) I have a text in the format "TeamA V. TeamB" (without quotes) i want to split the text into two values using StringRegExpReplace like $part1="TeamA" $part2="TeamB" ie part1 containts text upto "V." part2 containts text after "V." Also V. should be case in-sensitive(V. or v.) please help... Edited March 14, 2007 by maxilla
SadBunny Posted March 14, 2007 Posted March 14, 2007 (edited) still waiting...First, what did you try? If you show that you put some effort into it yourself you might get more help.Second, why not use StringSplit()?/edit: ok, StringSplit does not work case-insensitively I think... How about third: why not use StringInStr()?) Edited March 14, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
maxilla Posted March 14, 2007 Author Posted March 14, 2007 (edited) i read stringregexpreplace...but dint understand..i im a newbie plz help...can anyone gimme the code? Edited March 14, 2007 by maxilla
SadBunny Posted March 14, 2007 Posted March 14, 2007 i read stringregexpreplace...but dint understand..i im a newbie plz help...can anyone gimme the code?People here will generally give you suggestions or corrections if you post what you have tried so far. Again, my suggestion would be to go through them with StringInStr (it will give you the index of a substring in another string), and then get the left part up to this index in one var, and the right part from the end of the substring in another var? Roses are FF0000, violets are 0000FF... All my base are belong to you.
Moderators SmOke_N Posted March 14, 2007 Moderators Posted March 14, 2007 i read stringregexpreplace...but dint understand..i im a newbie plz help...can anyone gimme the code?So being a noob is reason to write the code for you without an ounce of effort on your part?... I would think that would be reserved for those that show effort on a consistent basis. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
maxilla Posted March 14, 2007 Author Posted March 14, 2007 hey i tried... $loc = StringInStr($FullText,"V.") $partA= StringTrimLeft($FullText, $loc+1) i got part A like this....but part B i dint get plz help
Moderators SmOke_N Posted March 14, 2007 Moderators Posted March 14, 2007 hey i tried... $loc = StringInStr($FullText,"V.") $partA= StringTrimLeft($FullText, $loc+1) i got part A like this....but part B i dint get plz helpUpload the text file you are searching... will take like 1 minute to get the code right . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
maxilla Posted March 14, 2007 Author Posted March 14, 2007 Not atext file n all...just one line stored in a varible $Fulltext I got location of "V." from left and using stringtrimleft to get part A how to get location of "V." from right so that i can use stringtrimright and get part B???
Moderators SmOke_N Posted March 14, 2007 Moderators Posted March 14, 2007 Not atext file n all...just one line stored in a varible $Fulltext I got location of "V." from left and using stringtrimleft to get part A how to get location of "V." from right so that i can use stringtrimright and get part B???I hate cloak and dagger.#include <array.au3> $sString = 'TeamA V. TeamB' $aArray = StringRegExp($sString, '(?s)(?i).*?(Team.)\s+V\.\s+(Team.)', 3) _ArrayDisplay($aArray, '')Time to start reading on what this does. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
maxilla Posted March 14, 2007 Author Posted March 14, 2007 GOD i was just giving teamA n team B as examples....there are thousands of different lines with the format partA V. partB ...plz giv a generalize solution... how to use stringinstr and get position of "V." from right??? then i can trim it using stringtrimright na???plz help
SadBunny Posted March 14, 2007 Posted March 14, 2007 Not atext file n all...just one line stored in a varible $FulltextI got location of "V." from left and using stringtrimleft to get part Ahow to get location of "V." from right so that i can use stringtrimright and get part B???Don't use StringTrim for this, since it in your case erases parts of the string that you still need. Instead, use StringLeft for reading the left part, and StringRight or StringMid to read the right part (you will need StringLen too to know how many characters from the right side you will need). Roses are FF0000, violets are 0000FF... All my base are belong to you.
damajor Posted March 14, 2007 Posted March 14, 2007 GOD i was just giving teamA n team B as examples....there are thousands of different lines with the format partA V. partB ...plz giv a generalize solution...how to use stringinstr and get position of "V." from right??? then i can trim it using stringtrimright na???plz helpTry to understand the regex, it is pretty easy in the given example.
maxilla Posted March 14, 2007 Author Posted March 14, 2007 NO stringtrim is enough ... $len=StringLen($fulltext) $loc = StringInStr($fulltext,"V.") $locr = $len-$loc $partA = StringTrimLeft($fulltext, $loc+1) $partB= StringTrimRight($fulltext, $locr+1) Thankssssssss.....
SadBunny Posted March 14, 2007 Posted March 14, 2007 NO stringtrim is enough ... $len=StringLen($fulltext) $loc = StringInStr($fulltext,"V.") $locr = $len-$loc $partA = StringTrimLeft($fulltext, $loc+1) $partB= StringTrimRight($fulltext, $locr+1) Thankssssssss.....Hey nice... Roses are FF0000, violets are 0000FF... All my base are belong to you.
seandisanti Posted March 14, 2007 Posted March 14, 2007 NO stringtrim is enough ... $len=StringLen($fulltext) $loc = StringInStr($fulltext,"V.") $locr = $len-$loc $partA = StringTrimLeft($fulltext, $loc+1) $partB= StringTrimRight($fulltext, $locr+1) Thankssssssss.....or if you're lazy (as i am) you could just: Dim $thestring = 'TeamA V. TeamB',$anarray $anarray = StringSplit($thestring,' V. ',1) For $x = 1 to $anarray[0] MsgBox(0,"Element " & $x,$anarray[$x]) Next
SadBunny Posted March 14, 2007 Posted March 14, 2007 (edited) or if you're lazy (as i am) you could just: Dim $thestring = 'TeamA V. TeamB',$anarray $anarray = StringSplit($thestring,' V. ',1) For $x = 1 to $anarray[0] MsgBox(0,"Element " & $x,$anarray[$x]) Next Edited March 14, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
SadBunny Posted March 14, 2007 Posted March 14, 2007 Or is stringsplit already case-INsensitive? Just tried it to be sure, but it seems indeed case-INsensitive! I didn't expect this since it is mentioned nowhere in the help file... I consider this an omission Sorry for my last post, I only tested my own code and that worked too Roses are FF0000, violets are 0000FF... All my base are belong to you.
seandisanti Posted March 14, 2007 Posted March 14, 2007 Or is stringsplit already case-INsensitive? Just tried it to be sure, but it seems indeed case-INsensitive! I didn't expect this since it is mentioned nowhere in the help file... I consider this an omission Sorry for my last post, I only tested my own code and that worked too I assumed based on the amount of data that it was being generated programatically so case would be uniform....
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