agentsclimarketplace

Run1 scala regex processing

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-gemini-3.1-pro-preview/python-scala-translation/run1_scala-regex-processing

Using regular expressions for text tokenization and parsing in Scala using the scala.util.matching.Regex API.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run1_scala-regex-processing

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.3 KB, 301 tokens by cl100k_base, as published. Nobody here has run it

String manipulation and tokenization rely heavily on Regular Expressions. Scala integrates regular expressions natively through scala.util.matching.Regex.

1. Creating Regular Expressions

Scala allows defining regex securely using raw strings ("""...""") and the .r method, avoiding the need to escape backslashes.

Python:

import re
pattern = re.compile(r'\s+')

Scala:

val whitespacePattern = """\s+""".r

2. Matching and Splitting

Python:

tokens = re.split(r'\s+', text)
matches = re.findall(r'\d+', text)

Scala:

// Splitting
val tokens: Array[String] = whitespacePattern.split(text)

// Finding all matches
val numberPattern = """\d+""".r
val matches: Iterator[String] = numberPattern.findAllIn(text)
val matchesList: List[String] = matches.toList

3. Pattern Matching with Regex

Scala allows using Regex as extractors in pattern matching:

val dateRegex = """(\d{4})-(\d{2})-(\d{2})""".r

text match {
  case dateRegex(year, month, day) => 
    println(s"Found date: Year $year, Month $month")
  case _ => 
    println("No date found")
}

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.