Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/23/2012 in all areas

  1. I'm trying to use a part of input text inside a regular expression without capturing the text in the match, but can't figure out how to construct the regex. Below is a snippet that shows what I'm trying to do, and what regex I've tried. Basically, the string is composed of sections that start with "foo", and there is no terminal string that denotes the end of a section. In other words, you know the section has ended when you run into the next "foo", or if you hit the end of the string. I'm trying to divide this string into an array of sections. (Note: you can copy the below input into http://regexpal.com/ rather than firing up LabVIEW) By best-shot regex: (foo[\s\S]*?)(?:foo)? An example input: foo text foo some more text foo some lorem ipsum text foo no more And the snippet: Any ideas?? Thanks in advance!
    1 point
  2. I've not come accross Quad-tree but I have come accross R-Tree
    1 point
  3. I have no idea, but I did read this post on the dark side just the other day and wondered what the heck a quadtree was...
    1 point
  4. I've just noticed a strange thing (LV2010SP1-LV2012), that when I run my application first, the default cursor icon for the mouse over a picture controls is the hand with the pointing finger. But then if I go into the icon editor, that application changes the icon over the picture control depending on what tool you have selected. After this, when I run my application now, it uses the last tool from the icon editor over all my picture controls. That must surely be a bug, don't you think? There is scripting property node I have to use to get around this in my VI, that sets the default icon of the picture control, it took me a while to find it. Cheers, Mike
    1 point
  5. It's buried in the help file, but you prefix your string with (?s) - the regex implementation in LV is pretty dirty. The correct format for a regular expression is [delimiter][expression[delimiter][options], e.g: /(foo(?:.(?!foo))+)/sgi, which is my solution for your problem (but LV doesn't like lookaround). I'm spoiled by all the time I spent working with proper PCRE. Well, you're parsing with regex - it's not the same thing as writing a parser. A true parser is written with the specific grammar of your subject in mind; not necessarily foo, followed by some stuff, and maybe another foo like the regex is doing. The "some stuff" part is something that regex is particularly bad for - unlimited quantifiers paired with dot or equivalent tend to be a sign that regex is the wrong tool. Regex is awesome when your subject is precise, but as you can see in your case, the variable-length payload is difficult to deal with elegantly. I bring this up especially because you mentioned that your header itself is variable, which is only going to further complicate things. You might be be successful with a regex, but it will be brittle and potentially very tedious to build. Technically, yes, you can write a true parser using regex (and that's probably okay) but there's a very clear line (to me) when you're trying to do too much with one regular expression. Darin's suggestion works correctly in LabVIEW (I don't think that it should), so you might be able to get away with finding an expression which works for the header and substituting it for your foo's.
    1 point
  6. I can not test, but I would actually use a positive look-ahead instead of the capture group. Try this: (foo[\s\S]*?)(?=foo|\z)
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.