View Single Post
  #1  
Old 28.02.2016, 02:51
Kino Kino is offline
Fibre Channel User
 
Join Date: Nov 2010
Posts: 116
Default Regex string separation help. (or splitting strings in to pieces)

Hi friends,

Suppose this is my packagename string.
text1-text2

I use (.*)-(.*) as regex rule to split this string.
Result:
<jd:orgpackagename:1> = text1
<jd:orgpackagename:2> = text2


That's good.

But if my packagename has two of "-" character like
text1-text2-text3

then result is:
<jd:orgpackagename:1> = text1-text2
<jd:orgpackagename:2> = text3


if my expectation is using first "-" character as separation point, how regex rule should I use?
In other words, for second case my expectation is this:
<jd:orgpackagename:1> = text1
<jd:orgpackagename:2> = text2-text3


A sample link to test:
**External links are only visible to Support Staff****External links are only visible to Support Staff**

With current rule, for the test link I get this:
<jd:orgpackagename:1> = Moero Knight-Monkey
<jd:orgpackagename:2> = Happy New Year


But my expectation is this:
<jd:orgpackagename:1> = Moero Knight
<jd:orgpackagename:2> = Monkey-Happy New Year


How should I modify my regex rule?
Reply With Quote