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 8470431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:31:00+00:00 2026-06-10T16:31:00+00:00

Say i have some rules and actions, like so , { do something; }

  • 0

Say i have some rules and actions, like so

,                   { do something; }
\.                  { do_something; }
\(                  { do_someting; }
\)                  { do_something); }
:                   { do_something; }
...

Whenever i match the a rule on the left, the action on the right gets called.
But what if i want to match everything else ? How could i do that?

using something like

.*          { do_something; }

won’t work because it also applies to the above rules.

  • 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-06-10T16:31:02+00:00Added an answer on June 10, 2026 at 4:31 pm

    According to the lex spec:

    During pattern matching, lex shall search the set of patterns for the
    single longest possible match. Among rules that match the same number
    of characters, the rule given first shall be chosen.

    So I would go with:

    .  { do_something; }
    

    …and put it as the last rule.

    This will match a single character, except for newline (“A <newline> shall not be matched by a period operator”). If you also want to match newline:

    .|\n  { do_something }
    

    Finally, if you do not actually want to consume the character, you need an extended regular expression (ERE) that matches the empty string. You could try:

    .{0}  { do_something }
    

    As I read the spec for lex and EREs, I believe that should work, but it would not surprise me if it tickled some bug somewhere 🙂

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

Sidebar

Related Questions

Say, we have some items, and each defines some partial sorting rules, like this:
Let's say I have a grammar defined to something like: some_rule := a b
Let's say I have some simple Javascript like: <script> var hello = function(){ alert(Hello
Let's say I have some code (using CherryPy) that looks like this: import cherrypy
Let's say I have some classes like this: abstract class View(val writer: XMLStreamWriter) {
let's say that I have some inputs with ID like that: ctl139_ctl00_txtValue ctl140_ctl00_txtValue ctl141_ctl00_txtValue
Say I have some 10 categories that I need to reference in a web
If say I have some generic class, for example: public class Attribute<T> { }
Let say i have some words AB, AAB, AA. AB is not a prefix
Lets say we have some basic AR model. class User < ActiveRecord::Base attr_accessible :firstname,

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.