Rank: Member
Joined: 8/21/2019 Posts: 10 Location: United Kingdom
|
I'll try to explain what I'm attempting to do.
I have a 'string' of words, and this string can be between 10 and 200 characters long.
I would like to find a way of splitting this string, but a maximum of 30 characters. But the string should not split in the middle of a word.
For this example, I've taken the below sentences from a 'random sentence generator' website
The fact that there's a stairway to heaven and a highway to hell explains life well. You can't compare apples and oranges, but what about bananas and plantains? As he looked out the window, he saw a clown walk by.
I will now mark out where the 30 character splits are:
The fact that there's a stairw|ay to heaven and a highway to |hell explains life well. You c|an't compare apples and orange|s, but what about bananas and |plantains? As he looked out th|e window, he saw a clown walk |by.
This is a problem, because the splits will looks like this:
1. The fact that there's a stairw 2. ay to heaven and a highway to 3. hell explains life well. You c 4. an't compare apples and orange 5. s, but what about bananas and 6. plantains? As he looked out th 7. e window, he saw a clown walk 8. by.
What I would like to do, is split these strings at the 'space' before the word thats being cut into (if that makes sense).... So like this:
The fact that there's a |stairway to heaven and a |highway to hell explains life |well. You can't compare apples |and oranges, but what about |bananas and plantains? As he |looked out the window, he saw |a clown walk by.
Resulting in the following splits:
1. The fact that there's a 2. stairway to heaven and a 3. highway to hell explains life 4. well. You can't compare apples 5. and oranges, but what about 6. bananas and plantains? As he 7. looked out the window, he saw 8. a clown walk by.
I hope this makes sense.
If someone can show me how to do this within MapForce that would be great.
Unfortunately I don't have any 'real' dummy data to hand, but essentially I'll be taking a string / splitting it (as per the example above) / and then placing it within an XML file. But I just need to know how to achieve the above effect.
I've read that RegEx might be able to do it and I tried to achieve this by using RegEx... But I can't seem to get the RegEx to work? I don't know anything about RegEx, so I'm unable to debug it.
|
Rank: Advanced Member
Joined: 2/27/2009 Posts: 564
|
I recall seeing a similar post about this beforeā¦
|
Rank: Advanced Member
Joined: 2/27/2009 Posts: 564
|
Have a look at this old topic.
|
Rank: Member
Joined: 8/21/2019 Posts: 10 Location: United Kingdom
|
That solution works perfectly K101 thank you very much!
|