mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.3 KiB
38 lines
1.3 KiB
5 years ago
|
## grouping
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
Write a program that receives two strings and replicates the use of brackets in regular expressions. Brackets in regular expressions returns the words that contain the expression inside of it.
|
||
|
|
||
|
The program should handle the "`|`" operator, that searches for both strings on each side of the operator.
|
||
|
|
||
![]()
5 years ago
|
The output of the program should be the results of the regular expression by order of appearance in the string, being themselves identified by a number.
|
||
5 years ago
|
|
||
![]()
4 years ago
|
If the number of arguments is different from 2, if the regular expression is not valid, if the last argument is empty or there are no matches the program should print nothing.
|
||
5 years ago
|
|
||
|
### Usage
|
||
|
|
||
|
```console
|
||
|
student@ubuntu:~/[[ROOT]]/test$ go build
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(a)" "I'm heavy, jumpsuit is on steady, Lighter when I'm lower, higher when I'm heavy"
|
||
|
1: heavy
|
||
|
2: steady
|
||
|
3: heavy
|
||
![]()
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(e|n)" "I currently have 4 windows opened up… and I don’t know why."
|
||
5 years ago
|
1: currently
|
||
|
2: currently
|
||
|
3: have
|
||
|
4: windows
|
||
![]()
5 years ago
|
5: opened
|
||
|
6: opened
|
||
5 years ago
|
7: and
|
||
|
8: don’t
|
||
|
9: know
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(hi)" "He swore he just saw his sushi move."
|
||
|
1: his
|
||
|
2: sushi
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(s)" ""
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "i" "Something in the air"
|
||
|
student@ubuntu:~/[[ROOT]]/test$
|
||
![]()
4 years ago
|
```
|