Hi, I have a text box and what I need is to separate two lines of text whenever I find a symbol # example
// Texarea1
#aaaaa
bbbbb
ccccc
ddddd
eeee
ffff
#eeeee
fffffff
Array
text(0) =
"#aaaaa
bbbbb"
text(1) =
"#eeeee
fffffff"
you have to group the two lines of text into an array, the array is conditioned by the symbol # at the beginning of the line
Unclear what you want to do here.
What happens (if anything) to the cccccc/ ddddd?
The following is written straight into the forum, and hasn’t been coded/tested.
Treat it as pseudo code
Take the text area’s text, and convert that into an array using Split , where the delimiter is the endofline character
[code]thearray = thetextarea.text.split(endofline) //may need to experiment to work out WHICH endofline is being used
//Now you have one array
//Use a loop to work through that array, creating your new one as you go
for x as integer = 0 to thearray.ubound - 1
if left(thearray(x),1) = “#” then
text.append thearray(x) + endofline + thearray(x+1)
end if
next
[/code]
If I understand this correctly, you want to take the text that’s in a TextArea and split it into an array so that each element is a line that starts with “#” and the line directly following it, right?
dim rx as new RegEx
rx.SearchPattern = "^#.*\\R.*"
dim arr() as string
dim match as RegExMatch = rx.Search( myTextArea.Text )
while match isa RegExMatch
arr.Append match.SubExpressionString( 0 )
match = rx.Search
wend
Thanks, the two examples work