Skip to content

Commit d2432aa

Browse files
committed
Merge pull request #26 from ArekCzarnik/1.x
make methode split workable with precompiled pattern
2 parents e22a356 + ad5ce71 commit d2432aa

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/main/java/rx/observables/StringObservable.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,36 @@ public String call(Object obj) {
368368
* <img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/St.split.png" alt="">
369369
*
370370
* @param src
371+
* the source that should be use for the split
371372
* @param regex
373+
* a string that build regular expression modifier
372374
* @return the Observable streaming the split values
373375
*/
376+
374377
public static Observable<String> split(final Observable<String> src, String regex) {
375-
final Pattern pattern = Pattern.compile(regex);
378+
Pattern pattern = Pattern.compile(regex);
379+
return StringObservable.split(src,pattern);
380+
}
381+
382+
/**
383+
* Rechunks the strings based on a regex pattern and works on infinite stream.
384+
*
385+
* <pre>
386+
* split(["boo:an", "d:foo"], ":") --> ["boo", "and", "foo"]
387+
* split(["boo:an", "d:foo"], "o") --> ["b", "", ":and:f", "", ""]
388+
* </pre>
389+
*
390+
* See {@link Pattern}
391+
* <p>
392+
* <img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/St.split.png" alt="">
393+
*
394+
* @param src
395+
* the source that should be use for the split
396+
* @param pattern
397+
* pre compiled regular expression pattern for the split functionality
398+
* @return the Observable streaming the split values
399+
*/
400+
public static Observable<String> split(final Observable<String> src, final Pattern pattern) {
376401

377402
return src.lift(new Operator<String, String>() {
378403
@Override

0 commit comments

Comments
 (0)