Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 506915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:45:01+00:00 2026-05-13T06:45:01+00:00

Regular Expressions are a complete void for me. I’m dealing with one right now

  • 0

Regular Expressions are a complete void for me.
I’m dealing with one right now in TextMate that does what I want it to do…but I don’t know WHY it does what I want it to do.

/[[:alpha:]]+|( )/(?1::$0)/g

This is used in a TextMate snippet and what it does is takes a Label and outputs it as an id name. So if I type “First Name” in the first spot, this outputs “FirstName”.
Previously it looked like this:

/[[:alpha:]]+|( )/(?1:_:/L$0)/g (it might have been \L instead)

This would turn “First Name” into “first_name”.
So I get that the underscore adds an underscore for a space, and that the /L lowercases everything…but I can’t figure out what the rest of it does or why.

Someone care to explain it piece by piece?

EDIT

Here is the actual snippet in question:

<column header="$1"><xmod:field name="${2:${1/[[:alpha:]]+|( )/(?1::$0)/g}}"/></column>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:45:01+00:00Added an answer on May 13, 2026 at 6:45 am

    This regular expression (regex) format is basically:

     /matchthis/replacewiththis/settings
    

    The “g” setting at the end means do a global replace, rather than just restricting the regex to a particular line or selection.

    Breaking it down further…

      [[:alpha:]]+|( )
    

    That matches an alpha numeric character (held in parameter $0), or optionally a space (held in matching parameter $1).

      (?1::$0)
    

    As Roger says, the ? indicates this part is a conditional. If a match was found in parameter $1 then it is replaced with the stuff between the colons :: – in this case nothing. If nothing is in $1 then the match is replaced with the contents of $0, i.e. any alphanumeric character that is not a space is output unchanged.

    This explains why the spaces are removed in the first example, and the spaces get replaced with underscores in your second example.

    In the second expression the \L is used to lowercase the text.

    The extra question in the comment was how to run this expression outside of TextMate. Using vi as an example, I would break it into multiple steps:

    :0,$s/ //g
    :0,$s/\u/\L\0/g
    

    The first part of the above commands tells vi to run a substitution starting on line 0 and ending at the end of the file (that’s what $ means).

    The rest of the expression uses the same sorts of rules as explained above, although some of the notation in vi is a bit custom – see this reference webpage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not new to Python but a complete newbie with regular expressions (on my
I'm trying to complete a regular expression that will pull out matches based on
Regular Expressions are usually expressed as strings, but they also have properties (ie. single
I've been trying to figure this out myself but I'm afraid Regular Expressions just
Regular expressions are great for text editing. But sometimes they aren't quite enough. For
I am new to regular expressions. I want to do multiline search. Here is
Regular expressions are often pointed to as the classical example of a language that
Im in the process of learning regular expressions but still cant really wrap my
Please don't answer the obvious, but what are the limit signs that tell us
Is it possible to make efficient queries that use the complete regular expression feature

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.