Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
baquerd
Jul 2, 2007

by FactsAreUseless

Kim Jong III posted:

Really the problem is that your question is so vague that it is impossible to answer. Are you trying to store properties for off the shelf services, or for something you wrote? What are the "user interface" issues you are having?

We have a variety of applications (all in-house) with key/value properties, most of which have multiple environments, which may or may not share properties between themselves at the environment level. This is already all organised into single database that this property management application controls, and we have another application that provides web service based access to the application properties. This allows us to point every application to the web service and let it pull it's properties out in a fairly standard way.

The problem is the software that manages the property store is extremely bare bones (essentially just a split view of the database tables that allows row updates). I'll probably end up just extending the functionality while keeping backwards compatibility, but I wanted to check to see if there were any gold standard application property management software packages I was unaware of.

Adbot
ADBOT LOVES YOU

Johnny Cache Hit
Oct 17, 2011

baquerd posted:

We have a variety of applications (all in-house) with key/value properties, most of which have multiple environments, which may or may not share properties between themselves at the environment level. This is already all organised into single database that this property management application controls, and we have another application that provides web service based access to the application properties. This allows us to point every application to the web service and let it pull it's properties out in a fairly standard way.

The problem is the software that manages the property store is extremely bare bones (essentially just a split view of the database tables that allows row updates). I'll probably end up just extending the functionality while keeping backwards compatibility, but I wanted to check to see if there were any gold standard application property management software packages I was unaware of.

Aaah, OK, I see what you're going for.

I've heard from some friends who do a lot of administration/operation that Chef works really well in the configuration space. I've never used it myself, and these guys do administration for a large enterprise so it might be overkill for your needs, but they swear by it.

ToxicFrog
Apr 26, 2008


shrughes posted:

Also [tail call optimization is] really only particularly helpful in event-loop based code with callback functions.

And state machines, and probably a few other cases I can't think of right now.

Wicaeed
Feb 8, 2005
Alright, I'm not a regex person by any means (and I don't know if there is a general regex thread), but I have the following regex string that is used to match entries in the Windows Hosts file

code:
\b([1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2})\b\s+([A-Za-z0-9._]+)(?:\s+)?(#.*)?
Right now it matches the comments, and I'd like to get it to NOT match any line starting with '#'

Let's just say I'm such a noob with regex that I can't figure out how to do this.

Any tips?

Look Around You
Jan 19, 2009

Wicaeed posted:

Alright, I'm not a regex person by any means (and I don't know if there is a general regex thread), but I have the following regex string that is used to match entries in the Windows Hosts file

code:
\b([1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}
[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2})\b\s+([A-Za-z0-9._]+)(?:\s+)?(#.*)?
Right now it matches the comments, and I'd like to get it to NOT match any line starting with '#'

Let's just say I'm such a noob with regex that I can't figure out how to do this.

Any tips?

:stare:

That... doesn't look like the right way to do this in general.

e:
What exactly are you trying to match the entries for? And shouldn't the hosts file just be comments and valid IPs/URIs?

Look Around You fucked around with this message at 19:16 on Mar 9, 2012

Wicaeed
Feb 8, 2005

Look Around You posted:

:stare:

That... doesn't look like the right way to do this in general.

http://regexr.com?3098q

Seriously, this is me and regex:




How would you approach the problem?

Details: This is going to be used by a Nessus file check template to make sure that the contents of the windows hosts file have not been changed to allow users to get around our URL web filtering software.

Wicaeed fucked around with this message at 19:17 on Mar 9, 2012

Look Around You
Jan 19, 2009

Wicaeed posted:

http://regexr.com?3098q

Seriously, this is me and regex:



What are you trying to do here that you (think you) need a regex for?

e:
Oh, ok. So you have a reference file that you're comparing it to then that they all need to be the same?

e2:
I'm actually going to defer here because I don't know anything about Nessus. That monster regex is probably not the best way to do this though.

Look Around You fucked around with this message at 19:22 on Mar 9, 2012

Wicaeed
Feb 8, 2005

Look Around You posted:

What are you trying to do here that you (think you) need a regex for?

e:
Oh, ok. So you have a reference file that you're comparing it to then that they all need to be the same?

hahaha, being able to upload/check vs. a reference file would be too easy.

The "reference file" in this case would be a standard windows hosts file (with only the commented out section). I'm (trying to) use regex to return only entries that have been added after the commented out section, that way if the file fails our audit we won't have to go to each computer and inspect the hosts file individually to find out what is there.

e1: Well with Nessus you can do file content scanning for PHI, CC#'s, SSNs, etc etc that all rely on regex

Wicaeed fucked around with this message at 19:28 on Mar 9, 2012

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Doesn't this sound more like you need a diff function than a regex matching.. whatever it is that is matching?

Essentially you diff on the current file and reference file and have it return you the difference.

Edit:
If you want to go the regex way, what you need to do is to use ^ to check to see if the start of the line matches the number so something like...
code:
^\s*([1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2}\.[1-2]{0,1}[0-9]{1,2})\s+([A-Za-z0-9._]+)(?:\s+)?(#.*)?
That regex site doesn't seem to understand ^ but I'm pretty sure that is valid in all regex parsers.

Strong Sauce fucked around with this message at 19:36 on Mar 9, 2012

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



You could look into "negative lookbehind" matches, although it is probably easier to use two regexes. Just start by filtering out all lines that match ^\s*# (ie they start with zero or more whitespace, then a comment hash).

Look Around You
Jan 19, 2009

Strong Sauce posted:

Doesn't this sound more like you need a diff function than a regex matching.. whatever it is that is matching?

Essentially you diff on the current file and reference file and have it return you the difference.

Edit:
If you want to go the regex way, what you need to do is to use ^ to check to see if the start of the line matches the number so something like...
code:
(HUGE loving MONSTER REGEX)
That regex site doesn't seem to understand ^ but I'm pretty sure that is valid in all regex parsers.

Honestly I was thinking of using a diff tool as well, that's what my question was leading to. I also fail to see how just matching regexes is going to do anything, unless you're comparing the matched results to a predefined list. Given that the Hosts file should be only valid URIs, couldn't you just do string comparisons to a given list (and therefore just use diff)?

Carthag's solution of using two regexes is probably the easiest way to handle this if you can only do regex matching for whatever reason though.

Johnny Cache Hit
Oct 17, 2011

Wicaeed posted:

hahaha, being able to upload/check vs. a reference file would be too easy.

The "reference file" in this case would be a standard windows hosts file (with only the commented out section). I'm (trying to) use regex to return only entries that have been added after the commented out section, that way if the file fails our audit we won't have to go to each computer and inspect the hosts file individually to find out what is there.

e1: Well with Nessus you can do file content scanning for PHI, CC#'s, SSNs, etc etc that all rely on regex

I mean there's nothing wrong with regexes but you really want to perform a difference between the original host file & the new one.

Does Nessus let you call an executable? You could ship diff.exe & just call that.

Wicaeed
Feb 8, 2005
The problem is that I don't have a reference file, or rather Nessus doesn't expect you to have one to use this feature. What it is doing is getting the contents of a file, then running regex to see if any contents match a certain string, for example, the following audit entry checks for cc #'s when scanning a computer. Obviously this takes a boatload of time:

code:
<item>
        type: FILE_CONTENT_CHECK
        description: "Determine if a file contains a valid American Express 15 digit credit card number."
        file_extension: "pdf" | "doc" | "xls" | "xlsx" | "xlsm" | "xlsb" | "xml" | "xltx" | "xltm" | "docx" | "docm" | "dotx" | "dot" | "txt"
        regex: "([^0-9-]|^)(3(4[0-9]{2}|7[0-9]{2})( |-|)[0-9]{6}( |-|)[0-9]{5})([^0-9-]|$)"
	regex_replace: "\3"
        expect: "American Express" | "CCAX" | "amex" | "credit" | "AMEX" | "CCN"
        max_size : "50K"
        only_show : "4"
</item>
I'm just trying to use it for a slightly different purpose.

Johnny Cache Hit
Oct 17, 2011

Wicaeed posted:

I'm just trying to use it for a slightly different purpose.

right but we're asking if you can put down the hammer for a minute and look through your toolbox for a screwdriver instead because it's gonna be a lot easier for you.

I mean if it's not possible to just look at the SHA of the hosts file, or you can't call a diff program, then you don't have a choice. But if there's an easier and much better way to do this you should look at that first.

Like here's a really basic file integrity check:
https://discussions.nessus.org/thread/4273

I can't find any good nessus docs, it seems. :/

Look Around You
Jan 19, 2009

Wicaeed posted:

The problem is that I don't have a reference file, or rather Nessus doesn't expect you to have one to use this feature. What it is doing is getting the contents of a file, then running regex to see if any contents match a certain string, for example, the following audit entry checks for cc #'s when scanning a computer. Obviously this takes a boatload of time:

code:
<item>
  (poo poo breaking tables)
</item>
I'm just trying to use it for a slightly different purpose.

:psyduck:

So all that does is look to see if there's any CC#s at all? It's just gonna blindly go through and pull out every card number then, which is what it's doing with your IP addresses. I don't think this will be useful at all because you expect the Hosts file to have IPs and URIs.

Wicaeed
Feb 8, 2005

Kim Jong III posted:

right but we're asking if you can put down the hammer for a minute and look through your toolbox for a screwdriver instead because it's gonna be a lot easier for you.

I mean if it's not possible to just look at the SHA of the hosts file, or you can't call a diff program, then you don't have a choice. But if there's an easier and much better way to do this you should look at that first.

Like here's a really basic file integrity check:
https://discussions.nessus.org/thread/4273

I can't find any good nessus docs, it seems. :/

poo poo that didn't even occur to me to do that. While of course it wont get me the actual entries, I could see that working a whole lot better.

edit: Actually this would present it's own set of problems, such as deploying a custom powershell cmdlet on each computer I want to run that command on.


Look Around You posted:

:psyduck:

So all that does is look to see if there's any CC#s at all? It's just gonna blindly go through and pull out every card number then, which is what it's doing with your IP addresses. I don't think this will be useful at all because you expect the Hosts file to have IPs and URIs.

Actually for our audit purposes (Domain Workstations where users SHOULDN'T have admin privileges) it would work very well, I think.

Wicaeed fucked around with this message at 20:43 on Mar 9, 2012

Goat Bastard
Oct 20, 2004

Wicaeed posted:

hahaha, being able to upload/check vs. a reference file would be too easy.

The "reference file" in this case would be a standard windows hosts file (with only the commented out section). I'm (trying to) use regex to return only entries that have been added after the commented out section, that way if the file fails our audit we won't have to go to each computer and inspect the hosts file individually to find out what is there.

e1: Well with Nessus you can do file content scanning for PHI, CC#'s, SSNs, etc etc that all rely on regex

If an expected file contains only comments then surely your regex just needs to match lines that don't start with a hash?

^[^#].*

Look Around You
Jan 19, 2009

Wicaeed posted:

hahaha, being able to upload/check vs. a reference file would be too easy.

The "reference file" in this case would be a standard windows hosts file (with only the commented out section). I'm (trying to) use regex to return only entries that have been added after the commented out section, that way if the file fails our audit we won't have to go to each computer and inspect the hosts file individually to find out what is there.

e1: Well with Nessus you can do file content scanning for PHI, CC#'s, SSNs, etc etc that all rely on regex

I didn't see this earlier. If this is the case than literally all you need to do is get the MD5 (or SHA or w/e) of the individual machines and compare it to the hash of the standard file. If you want to see what changes were made (if any) then you could use a diff. Either way, there's absolutely no reason you need to use a regex here.

e: Kim Jong III even gave a link on how to do a check with an md5 or whatever.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Goat Bastard posted:

If an expected file contains only comments then surely your regex just needs to match lines that don't start with a hash?

^[^#].*

That doesn't do what you think it does.

Generally when you're trying to get rid of comments etc, it's better to blacklist than wwhitelist. That regex will whitelist stuff that shouldn't be.

hayden.
Sep 11, 2007

here's a goat on a pig or something
Not really a programming question, but how does Portland compare to Seattle in terms of decent programming jobs available? I would assume there'd be a fair bit more in Seattle but who knows.

Sidpret
Jun 17, 2004

I need a pointer on something cause I'm really not even sure what to google for. I want to download a large number of files from a site. Usually I would just wget but the files I need are queried by the site for download, so there aren't URLs.

Here's an example of a query from the site that fetches a particular document:

www.reginfo.gov/public/do/eAgendaViewRule?pubId=200910&RIN=1904-AA92&operation=OPERATION_EXPORT_XML

I know python and am decent with the bash terminal so those are my tools. I will need to generate thousands of queries and I can handle that part. The part I don't really get is literally just how to request that file in bash or python and have it appear on my desktop. Could anyone point me in the right direction?

floWenoL
Oct 23, 2002

Sidpret posted:

I need a pointer on something cause I'm really not even sure what to google for. I want to download a large number of files from a site. Usually I would just wget but the files I need are queried by the site for download, so there aren't URLs.

Here's an example of a query from the site that fetches a particular document:

https://www.reginfo.gov/public/do/eAgendaViewRule?pubId=200910&RIN=1904-AA92&operation=OPERATION_EXPORT_XML

I know python and am decent with the bash terminal so those are my tools. I will need to generate thousands of queries and I can handle that part. The part I don't really get is literally just how to request that file in bash or python and have it appear on my desktop. Could anyone point me in the right direction?

Why not shell out from bash/python to wget?

Sidpret
Jun 17, 2004

floWenoL posted:

Why not shell out from bash/python to wget?

Wget doesn't work. Or maybe it would with appropriate options? I don't know wget that well. But like if you just wget that link I gave it will not fetch the appropriate file, and will instead return their 404 page.

pseudorandom name
May 6, 2007

wget won't work at the shell prompt if you're not quoting the URLs; those &blah=blah will get cut off.

Sidpret
Jun 17, 2004

pseudorandom name posted:

wget won't work at the shell prompt if you're not quoting the URLs; those &blah=blah will get cut off.

Oh wow that was it. Thanks guys :)

Goat Bastard
Oct 20, 2004

Carthag posted:

That doesn't do what you think it does.

Generally when you're trying to get rid of comments etc, it's better to blacklist than wwhitelist. That regex will whitelist stuff that shouldn't be.

How do you mean? An invalid line is a line that isn't a comment (this doesn't guarantee that the file hasn't been edited, but does guarantee that any edits don't actually DO anything). A comment is a line that starts with a hash (a comment starting partway through a line is still an unexpected line). That regex matches any line that starts with a character other than a hash. Since he described the problem as "I want to write a regex to match unexpected lines", this sounds exactly like a blacklist to me.

Not saying I haven't missed something, but other than new comments (which aren't dangerous - he stated he is looking for people using the host file to circumvent their proxy, which to my knowledge you can't do by writing a bunch of comments) I don't see how this will allow any lines that he doesn't want.

Total Meatlove
Jan 28, 2007

:japan:
Rangers died, shoujo Hitler cried ;_;
I'm trying to write a macro for Word. I have done some before but I ended up working out how to do everything I needed in find and replace and then just recording it. I have no experience with VB at all, but it seems like the only way of getting this done the way I want it.

Each document is made up of mini reports, laid out as a table but in text. I want to search through the document, find a specific report, copy a specific column (because the number of rows fluctuates day to day) and then copy that into a separate document.

So from this example

code:
Start of report.

From LONDON to LEEDS

000100101 Bake2 AKSKD 00D00W
001010110 Bake4 AKASN 02DJCK
010101010 Bake5 SJABB 93JD99
010101001 Bake9 ABSJB WW29DN
010101010 Bake3 BAJSB 203NDJ

end of report.
I just want the Bake column copied and pasted. Is that possible?

I mean in terms of just recording one, I know that (From LONDON to LEEDS)*(Bake?)*(end of report.) replaced with \2 would get me close to what I want, is there a way of getting all instances of (Bake?) in that specific report selected as one and then deleting the rest?

The Gripper
Sep 14, 2004
i am winner

Fat Guy Sexting posted:

I mean in terms of just recording one, I know that (From LONDON to LEEDS)*(Bake?)*(end of report.) replaced with \2 would get me close to what I want, is there a way of getting all instances of (Bake?) in that specific report selected as one and then deleting the rest?
Because I couldn't stand starting something and not finishing, here's something that should work for you http://pastebin.com/Uxqf47af

Run the macro, enter your source and destination cities and it should pull the data from the subreports, dumping column 2 into a new document. I tested it out with a few copy/pastes of the sample data with differing locations and had no issue. You could probably change the input from an inputbox to a drop-down box of locations and select from that.

It probably requires some more error-checking (currently if it can't find the "From <city1> to <city2>" line it stops the macro, but if for some reason the subreport has no "end of report." footer it'll select extra text until it finds the next one), but other than that it seems fine.

All it does is search for From <term1> to <term2>, sets the start of the range to select as 2 characters after that, then searches for "end of report." and sets the end of the range to select as 2 characters before that. It then converts the text to a table (auto-delimited), selects Column 2 and copies that to a second document.

Edit; and here's a copy that you can bind to a key, and (with the cursor inside the subreport you want) run the macro and it'll pull column 2 out of that specific report http://pastebin.com/bgbvtZA6

The Gripper fucked around with this message at 12:42 on Mar 12, 2012

hayden.
Sep 11, 2007

here's a goat on a pig or something
To generate random numbers in Java, you'd do something like this:

code:
Random diceRoller = new Random();
for (int i = 0; i < 10; i++) {
  int roll = diceRoller.nextInt(6) + 1;
  System.out.println(roll);
}
Why is it that Java is developed in such a way that you have to create a Random object and then call methods of that object? Why can't they just have static methods available for doing this and the tons of other stuff that requires the creation of objects? This isn't really the sort of thing that any of the few textbooks I've read discuss.

hayden. fucked around with this message at 01:55 on Mar 13, 2012

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
hayden:

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
It also lets you create your own implementations to work for whatever specific requirements you have.

Also there is the case where multiple threads are generating random numbers. If there were a single RNG all of them would have to synchronize on that somehow; this way they can each have their own local RNG.

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

Internet Janitor posted:

  • Having a Random object makes sense because a random number generator, by definition, maintains state. There are many good reasons for not having a single global RNG such as testability.

This. When you create a Random object, you have the option to pass in a seed. If you use the same seed, the generator will pump out the same series of numbers every time. If you don't use the constructor where you pass a seed (or use Math.Random), it uses the current value of the system's clock as the seed so you'll, in theory, never get the same series of numbers ever, which is generally what you want. But, like was said above, having the same values come out makes testing a lot easier and there are other applications where this is desirable, the example at the top of my head being seeding the terrain generator in a Worms game.

low quality jpeg
Mar 10, 2012

Would anyone be interested in a Processing thread? It's my language of choice at the moment and I wonder what goons do with it, though I'm not sure if enough people use it

Kire
Aug 25, 2006
In Processing, how do I use super() to create a subclass which inherits the traits of the parent class? Relevant part is at the end:

code:
class Car { 
  color c;
  float xpos;
  float ypos;
  float yspeed;

  Car(color tempC, float tempXpos, float tempYpos, float tempYspeed) { 
    c = tempC;
    xpos = tempXpos;
    ypos = tempYpos;
    yspeed = tempYspeed;
  }

  void display() {
    stroke(0);
    fill(c);
    rectMode(CENTER); 
    rect(xpos,ypos,10,20);
  }

  void drive() {
    ypos = ypos + yspeed;
    if (ypos > height) {
      ypos = 0;
    }
  }
  
  float[] location() {
    float x = modelX(0,0,0);
    float y = modelY(0,0,0);
    float[] pos = {x,y};
    return pos;
  }
}

class SUV extends Car {
  float Scaled;
  
  SUV(float Scaled, color tempC, float tempXpos, float tempYpos, float tempYspeed) {
    super(c, xpos, ypos, yspeed);
    scale(Scaled);
  }
}
That SUV class at the bottom is a mess because I can't figure out the syntax for getting it to have the same color, xpos, ypos, and yspeed of a Car but with the added scale() size (I want them to be bigger by some amount Scaled).

edit: wow just noticed the above post.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I don't know anything about Processing, but it doesn't look like you're using super correctly. It should be:

code:
class SUV extends Car {
  float Scaled;
  
  SUV(float tempScaled, color tempC, float tempXpos, float tempYpos, float tempYspeed) {
    super(tempScaped, tempC, tempXpos, tempYpos, tempYspeed);
    Scaled = tempScaled;
  }
}

The Gripper
Sep 14, 2004
i am winner
^^Edit; pretty much this, except you don't want to pass tempScaled into super()

The inheritance example in the documentation has the exact solution you're needing - see class SpinSpots extends Spin {}

You're using super() correctly but not passing the right variable names in, and not setting Scaled properly. Change the constructor to:
code:
SUV(float tempScaled, color tempC, float tempXpos, float tempYpos, float tempYspeed) {
    super(tempC, tempXpos, tempYpos, tempYspeed);
    Scaled = tempScaled;
  }
Note: I made the variable name tempScaled instead of Scaled as otherwise you'd be doing Scaled = Scaled;, which wouldn't work.

This won't magically scale your model down (I don't know what the call to scale() is), so you'll likely need to call scale(Scaled) later

The Gripper fucked around with this message at 08:31 on Mar 15, 2012

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I recently got the worst SDK ever for something with source code examples in C++, C#, Java, and VB of various flavors. The Java code has some actual comments in it, but due to a missing DLL in the installation I can't run it. The other examples simply don't work. I actually was more successful before when I was scraping stuff together from crap online--at least I can connect to the device in my code! I decided to try all the other language examples and it was all the same--if I could compile it at all.

In the C++ project, I found a note about the source being generated by AppWizard. I've looked this up and got various things:

1. OGRE's got one for generating projects, as far as I can tell.
2. There's one for app generation on the iPhone.
3. AppWizard is short for application wizard in some part of the normal windows development process, but certainly not for making GBS threads out stuff in different languages.

I wondered if anybody had heard of an AppWizard thing that generates code for different languages from some base code. It could be I'm misinterpreting what it's doing. I ask because the SDK comes with demo programs that do work, but they don't have source. I am assuming if I can figure out the base code, then that's likely the one that works of the whole lot.

...but chances are that I'll just have to wing it from the source code because I've already been more successful. :( I'll have to just suck out all the magic numbers from their source and use them in my stuff.

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy
AppWizard is the Visual Studio component that generates a skeleton C++ program. IIRC all it does is set up the project to include precompiled headers, link to MFC, etc.

calcio
May 7, 2007

No Totti No party
Looking for an alternate way to validate an ISBN 10 using regex. At least everything but the checksum.

It must start with a digit and must end with a digit or X. And it can contain exactly 0 or 3 hyphens with none of the hyphens sequential.

Using regex, I believe the expression must start with ^\d and end with [\d|X]$. Building the middle I'm becoming stumped getting it to work.

Adbot
ADBOT LOVES YOU

Look Around You
Jan 19, 2009

calcio posted:

Looking for an alternate way to validate an ISBN 10 using regex. At least everything but the checksum.

It must start with a digit and must end with a digit or X. And it can contain exactly 0 or 3 hyphens with none of the hyphens sequential.

Using regex, I believe the expression must start with ^\d and end with [\d|X]$. Building the middle I'm becoming stumped getting it to work.

I don't know if this is actually able to be expressed with a regex... it doesn't sound like a regular language to me.

Note that I could be wrong though; I don't remember all that much of my formal methods class w/r/t regular languages and the pumping lemma and stuff.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply