JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 28.02.2016, 03: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
  #2  
Old 28.02.2016, 04:09
tony2long's Avatar
tony2long tony2long is offline
English Supporter
 
Join Date: Jun 2009
Posts: 6,386
Default

Try this: (.*?)-(.*)
__________________
FAQ: How to upload a Log
Reply With Quote
  #3  
Old 28.02.2016, 20:15
Kino Kino is offline
Fibre Channel User
 
Join Date: Nov 2010
Posts: 116
Default Yes!

:thumbup:
Yes, this is what I'm looking for.
Thanks a lot.

By the way as you may guess, I'm a real and %100 newbie in regex.
Could you please advice me some document or web page as reference (with many examples, if possible)?
I've seen so many programs using regex but I'm completely out because of my ignorance.
Reply With Quote
  #4  
Old 28.02.2016, 20:38
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 67,541
Default

I suggest to google for regex and wikipedia is a good start
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 19:11.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.