Jump to content

String to 2D array


Sodori
 Share

Recommended Posts

Local $a1 = StringRegExp($str, '.+', 3)
And cleaner and cleaner.

To create blank rows in the array from blank lines in the string.  

And, not create a blank row at the end of the array regardless of a trailing line feed in string.

Then this appears to work.

Local $a1 = StringRegExp($str, '(.*)(?:\R)|.+$', 3)
Edit: Changed from '(.*(?:R)|.+$)', because the outside capture group, (....), is capturing the non-capture group, (?:R), causing the line feeds to exist in the array elements. Edited by Malkey
Link to comment
Share on other sites

does (?:R) mean excluding the enter line?

Yes.

The "R" is matched in the test string, but is not captured. That is, the line feed will not appear in the result of the Reg Exp. function.

See my post#22 Edit.

However, this "(?:R)" non-capture group can be captured if enclosed within a capture group as I mistakenly did in post #22.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...