Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nereide
plugins
Hyperion
Commits
91a982f3
Commit
91a982f3
authored
Jan 28, 2021
by
gtchaboussie@gmail.com
Browse files
Cleanup service
parent
ecd06f62
Changes
1
Hide whitespace changes
Inline
Side-by-side
groovyScripts/regex/RegexService.groovy
View file @
91a982f3
...
...
@@ -17,41 +17,23 @@
* under the License.
*/
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* Un service doit retourner une map
* Map<String, Object> obligatoirement
*
* Extrait de compte :
* /I/VT4712-102VANDEMOORTELE BAKE VANDEMOORTELE BAKERY PRODUCTS FRANCE /I/VT4712-1025/I/VT4712-1374 3434000200
* Pour rappel, on cherche à récupérer des chaines de type suivant
* VT4712-102
* VT4712-1025
* VT4712-1374
* On attends 3 chaines, sous forme de liste
*
* A priori ça marche.
* Maintenant, à gérer le cas ou il n'y a pas eu de match
* Function that takes a String parameter, and compares it to
* hard-coded regex.
* Outputs a List of found matches
* @return List
*/
def
test
()
{
Map
resultMap
=
success
()
List
results
=
[]
String
phrase
=
parameters
.
regexInput
/**
* Le regex prends en l'état un en tête fixe ( VT4712- )
* puis un nombre variable de chiffres
*/
Pattern
pattern
=
Pattern
.
compile
(
"VT4712-\\d+"
)
// ouverture du comparateur & test
Matcher
matcher
=
pattern
.
matcher
(
phrase
)
int
count
=
0
...
...
@@ -59,14 +41,6 @@ def test() {
count
++
results
.
add
(
matcher
.
group
())
}
resultMap
.
results
=
results
logInfo
(
resultMap
.
toString
())
logInfo
(
"#############################"
)
return
resultMap
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment