VoiceGem

How to dictate a Java regex with double backslashes

Java requires every regex backslash to be doubled inside a string literal, and this is the one language where dictation makes that easier rather than harder. Saying “backslash backslash d” returns \\d with no space, because the backslash attaches on both sides.

A thirteen-word compile call takes roughly 15 seconds to type and roughly 4.8 seconds to say. (sources: Dhakal, Feit, Kristensson & Oulasvirta, “Observations on Typing from 136 Million Keystrokes”, CHI 2018, 168,000 participants, 136 million keystrokes; Yuan, Liberman & Cieri, “Towards an Integrated Understanding of Speaking Rate in Conversation”, Interspeech 2006, 2,438 American English telephone conversations (Switchboard corpus). The speech figure is conversational rate, not a measured dictation rate — no such measurement exists.)

What lands in your editor
Pattern.compile("\\d +")

This tool runs entirely in your browser. Nothing you type is sent anywhere, stored, or logged.

Step by step

  1. 1

    Say the class and method

    Speak “pascal case pattern dot compile”. The period attaches on both sides, so the call arrives closed up.

  2. 2

    Open the string literal

    Say “open paren double quote”. Both bind tightly in VoiceGem's table, so the literal starts flush inside the bracket.

  3. 3

    Say “backslash backslash” for every escape

    Speak the phrase twice per escape. Each backslash binds on both sides, so the two characters arrive adjacent with nothing between them.

  4. 4

    Strip the quantifier spaces

    Close the gaps around plus and star before compiling. The escapes are clean; the quantifiers are not.

Java double escaping is the one regex detail dictation genuinely improves

Counting backslashes on screen is the classic Java regex mistake: \d in the pattern is \\d in the source, and a missing one produces a pattern that compiles and matches the wrong thing. Reading two adjacent backslashes and being sure there are exactly two is a genuinely hard visual task.

Saying it is easier than seeing it. “Backslash backslash d” is two words you either said or did not, and VoiceGem's backslash attaches on both sides so the pair lands adjacent every time. This is the only place in the whole set where the Deterministic Pass makes a correctness problem easier rather than merely faster.

Where the manual way breaks

IntelliJ highlights regex syntax inside string literals and will warn about several classes of mistake, which is real help typing has and speaking does not.

Backslash counting is where the highlighting does least. A pattern with four escaped classes is eight backslashes in the source, and the editor cannot tell you that you meant three of one and one of another. Dictating the pattern in VoiceGem turns the count into words rather than pixels.

Doing this somewhere else? speech-to-code converter, in one place, what changes for dictating Javadoc comments, dictating Java methods, step by step, or the same thing for naming things in Java by voice.

Common questions

Say “backslash backslash” then the letter. Each VoiceGem backslash binds on both sides, so the pair arrives adjacent with no space.

Yes. Plus, star and brace quantifiers all keep their spaces, so strip the whitespace before calling Pattern.compile.

Yes. Its regex highlighting inside string literals works the same on dictated text as on typed text, so use both.

Dictate four escaped classes and count the backslashes you hear.

Open the tool