Regular expression to split a long string

K

Kerry

Please help if you can.

I have a web form that has a multiline input box 30 columns by 15 rows. The
maximum length of a user's entry can be 450 characters. I need to read this
data into a series of 15 database fields (each 30 characters wide). I know
this amounts to poor normalization, btu the system is old and cannot be
maintained under the current project.

I need to accept the user's entry in this textbox and split it into (up to)
15 strings, no wider than 30 characters each. Ideally, splits will occur
where newline characters occur or after each 30th character. I have
experimented with many different regular expressions similar to

"((?m:(.{1,30})\n?){1,15})"

but I can't get the separate strings.

Has anyone tried something like this successfully?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top