Documentation
¶
Index ¶
- func FilterMatch[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
- func FilterMatchString[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
- func Find[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
- func FindAll[T ~[]byte](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[][]byte]
- func FindAllString[T ~string](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[]string]
- func FindAllStringSubmatch[T ~string](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[][]string]
- func FindAllSubmatch[T ~[]byte](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[][][]byte]
- func FindString[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
- func FindStringSubmatch[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[[]string]
- func FindSubmatch[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[[][]byte]
- func Match[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[bool]
- func MatchString[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[bool]
- func ReplaceAll[T ~[]byte](pattern *regexp.Regexp, repl T) func(ro.Observable[T]) ro.Observable[T]
- func ReplaceAllString[T ~string](pattern *regexp.Regexp, repl T) func(ro.Observable[T]) ro.Observable[T]
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterMatch ¶
func FilterMatch[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
FilterMatch filters the byte slice if it matches the pattern.
Example ¶
// Filter byte slices that match pattern
pattern := regexp.MustCompile(`^\d+$`)
observable := ro.Pipe1(
ro.Just(
[]byte("123"),
[]byte("abc"),
[]byte("456"),
[]byte("def"),
),
FilterMatch[[]byte](pattern),
)
subscription := observable.Subscribe(ro.PrintObserver[[]byte]())
defer subscription.Unsubscribe()
Output: Next: [49 50 51] Next: [52 53 54] Completed
func FilterMatchString ¶
func FilterMatchString[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
FilterMatchString filters the string if it matches the pattern. Play: https://go.dev/play/p/9hM7n8kL5jU
Example ¶
// Filter strings that match pattern pattern := regexp.MustCompile(`^\d+$`) observable := ro.Pipe1( ro.Just( "123", "abc", "456", "def", ), FilterMatchString[string](pattern), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: 123 Next: 456 Completed
func Find ¶
func Find[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
Find finds the first match of the pattern in the byte slice. Play: https://go.dev/play/p/9hM7n8kL5jU
Example ¶
// Find first match in byte slices
pattern := regexp.MustCompile(`\d+`)
observable := ro.Pipe1(
ro.Just(
[]byte("Hello 123 World"),
[]byte("Test 456 Example"),
[]byte("No numbers here"),
),
Find[[]byte](pattern),
)
subscription := observable.Subscribe(ro.PrintObserver[[]byte]())
defer subscription.Unsubscribe()
Output: Next: [49 50 51] Next: [52 53 54] Next: [] Completed
func FindAll ¶
func FindAll[T ~[]byte](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[][]byte]
FindAll finds all matches of the pattern in the byte slice.
Example ¶
// Find all matches in byte slices
pattern := regexp.MustCompile(`\d+`)
observable := ro.Pipe1(
ro.Just(
[]byte("Hello 123 World 456"),
[]byte("Test 789 Example"),
[]byte("No numbers here"),
),
FindAll[[]byte](pattern, -1),
)
subscription := observable.Subscribe(ro.PrintObserver[[][]byte]())
defer subscription.Unsubscribe()
Output: Next: [[49 50 51] [52 53 54]] Next: [[55 56 57]] Next: [] Completed
func FindAllString ¶
func FindAllString[T ~string](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[]string]
FindAllString finds all matches of the pattern in the string.
Example ¶
// Find all matches in strings pattern := regexp.MustCompile(`\d+`) observable := ro.Pipe1( ro.Just( "Hello 123 World 456", "Test 789 Example", "No numbers here", ), FindAllString[string](pattern, -1), ) subscription := observable.Subscribe(ro.PrintObserver[[]string]()) defer subscription.Unsubscribe()
Output: Next: [123 456] Next: [789] Next: [] Completed
func FindAllStringSubmatch ¶
func FindAllStringSubmatch[T ~string](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[][]string]
FindAllStringSubmatch finds all submatches of the pattern in the string.
Example ¶
// Find all submatches in strings pattern := regexp.MustCompile(`(\d+)-(\w+)`) observable := ro.Pipe1( ro.Just( "123-abc 456-def", "789-ghi", "No matches", ), FindAllStringSubmatch[string](pattern, -1), ) subscription := observable.Subscribe(ro.PrintObserver[[][]string]()) defer subscription.Unsubscribe()
Output: Next: [[123-abc 123 abc] [456-def 456 def]] Next: [[789-ghi 789 ghi]] Next: [] Completed
func FindAllSubmatch ¶
func FindAllSubmatch[T ~[]byte](pattern *regexp.Regexp, n int) func(ro.Observable[T]) ro.Observable[[][][]byte]
FindAllSubmatch finds all submatches of the pattern in the byte slice.
Example ¶
// Find all submatches in byte slices
pattern := regexp.MustCompile(`(\d+)-(\w+)`)
observable := ro.Pipe1(
ro.Just(
[]byte("123-abc 456-def"),
[]byte("789-ghi"),
[]byte("No matches"),
),
FindAllSubmatch[[]byte](pattern, -1),
)
subscription := observable.Subscribe(ro.PrintObserver[[][][]byte]())
defer subscription.Unsubscribe()
Output: Next: [[[49 50 51 45 97 98 99] [49 50 51] [97 98 99]] [[52 53 54 45 100 101 102] [52 53 54] [100 101 102]]] Next: [[[55 56 57 45 103 104 105] [55 56 57] [103 104 105]]] Next: [] Completed
func FindString ¶
func FindString[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[T]
FindString finds the first match of the pattern in the string.
Example ¶
// Find first match in strings
pattern := regexp.MustCompile(`\d+`)
observable := ro.Pipe2(
ro.Just(
"Hello 123 World",
"Test 4567 Example",
"No numbers here",
),
FindString[string](pattern),
ro.Map(func(s string) int {
return len(s)
}),
)
subscription := observable.Subscribe(ro.PrintObserver[int]())
defer subscription.Unsubscribe()
Output: Next: 3 Next: 4 Next: 0 Completed
func FindStringSubmatch ¶
func FindStringSubmatch[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[[]string]
FindStringSubmatch finds the first submatch of the pattern in the string.
Example ¶
// Find first submatch in strings pattern := regexp.MustCompile(`(\d+)-(\w+)`) observable := ro.Pipe1( ro.Just( "123-abc", "456-def", "No match", ), FindStringSubmatch[string](pattern), ) subscription := observable.Subscribe(ro.PrintObserver[[]string]()) defer subscription.Unsubscribe()
Output: Next: [123-abc 123 abc] Next: [456-def 456 def] Next: [] Completed
func FindSubmatch ¶
func FindSubmatch[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[[][]byte]
FindSubmatch finds the first submatch of the pattern in the byte slice.
Example ¶
// Find first submatch in byte slices
pattern := regexp.MustCompile(`(\d+)-(\w+)`)
observable := ro.Pipe1(
ro.Just(
[]byte("123-abc"),
[]byte("456-def"),
[]byte("No match"),
),
FindSubmatch[[]byte](pattern),
)
subscription := observable.Subscribe(ro.PrintObserver[[][]byte]())
defer subscription.Unsubscribe()
Output: Next: [[49 50 51 45 97 98 99] [49 50 51] [97 98 99]] Next: [[52 53 54 45 100 101 102] [52 53 54] [100 101 102]] Next: [] Completed
func Match ¶
func Match[T ~[]byte](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[bool]
Match checks if the pattern matches the byte slice.
Example ¶
// Check if byte slices match pattern
pattern := regexp.MustCompile(`^\d+$`)
observable := ro.Pipe1(
ro.Just(
[]byte("123"),
[]byte("abc"),
[]byte("456"),
),
Match[[]byte](pattern),
)
subscription := observable.Subscribe(ro.PrintObserver[bool]())
defer subscription.Unsubscribe()
Output: Next: true Next: false Next: true Completed
func MatchString ¶
func MatchString[T ~string](pattern *regexp.Regexp) func(ro.Observable[T]) ro.Observable[bool]
MatchString checks if the pattern matches the string.
Example ¶
// Check if strings match pattern pattern := regexp.MustCompile(`^\d+$`) observable := ro.Pipe1( ro.Just( "123", "abc", "456", ), MatchString[string](pattern), ) subscription := observable.Subscribe(ro.PrintObserver[bool]()) defer subscription.Unsubscribe()
Output: Next: true Next: false Next: true Completed
func ReplaceAll ¶
func ReplaceAll[T ~[]byte](pattern *regexp.Regexp, repl T) func(ro.Observable[T]) ro.Observable[T]
ReplaceAll replaces all matches of the pattern in the byte slice with the replacement.
Example ¶
// Replace matches in byte slices
pattern := regexp.MustCompile(`\d+`)
observable := ro.Pipe1(
ro.Just(
[]byte("Hello 123 World"),
[]byte("Test 456 Example"),
),
ReplaceAll[[]byte](pattern, []byte("XXX")),
)
subscription := observable.Subscribe(ro.PrintObserver[[]byte]())
defer subscription.Unsubscribe()
Output: Next: [72 101 108 108 111 32 88 88 88 32 87 111 114 108 100] Next: [84 101 115 116 32 88 88 88 32 69 120 97 109 112 108 101] Completed
func ReplaceAllString ¶
func ReplaceAllString[T ~string](pattern *regexp.Regexp, repl T) func(ro.Observable[T]) ro.Observable[T]
ReplaceAllString replaces all matches of the pattern in the string with the replacement.
Example ¶
// Replace matches in strings pattern := regexp.MustCompile(`\d+`) observable := ro.Pipe1( ro.Just( "Hello 123 World", "Test 456 Example", ), ReplaceAllString[string](pattern, "XXX"), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: Hello XXX World Next: Test XXX Example Completed
Types ¶
This section is empty.