www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Regular expression question

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Location
    Jackson MS
    Posts
    374

    resolved [RESOLVED] Regular expression question

    In something to read clipboard data from a music notation program, I am not interested in a note if it has the Grace attribute, stem direction is missing, or spacing has already been applied. The following would fail
    Code:
    |Note|Dur:8th,Grace,Slur|Pos:#-1|Opts:Stem=Down,XAccSpace=1,XNoteSpace=1
    for three reasons, but is the basis for a regular expression:
    Code:
        result = lineU[iU].match(/\|Note\|Dur:.*(Grace)?.*Pos:([x#nbv]?)(-?\d*).*Stem=(Up|Down).*(Space=)?/)      // Look for |Note| with Stem=Up specfied, not Grace, no Space=
        if ((result != null) && (result[1] == "") && (result[5] == "")) {
    Something that SHOULD pass is
    Code:
    |Note|Dur:4th|Pos:-2|Opts:Stem=Down
    When I ran this in debugging mode, nothing was displayed for result[1] or [5] although result[2] was "" (No accidental). My question is how can I check for empty results in these two positions? TIA

  2. #2
    Join Date
    Sep 2008
    Location
    Jackson MS
    Posts
    374
    Never mind. I am now checking for null rather than an empty string.

  3. #3
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,276
    Use test with something like this
    Code:
    var lnU=lineU[iU]
    if ((!/Grace/.test(lnU)) && /Stem=(Up|Down)/.test(lnU) && (!/XNoteSpace=1/.test(lnU))) {
       // I am interested
    }
    Last edited by 007Julien; 12-04-2012 at 11:52 AM.

  4. #4
    Join Date
    Sep 2008
    Location
    Jackson MS
    Posts
    374
    I hadn't thought of doing a test in that order, but I'll have to keep that in mind for the future, thanks for looking at it. It worked when I checked for null so I uploaded it to spacepart.htm. Some test data:
    Code:
    !NoteWorthyComposerClip(2.5,Single)
    |Clef|Type:Treble
    |Note|Dur:4th|Pos:-1|Opts:Stem=Up
    |Note|Dur:4th|Pos:-1|Opts:Stem=Up
    |Note|Dur:4th|Pos:#-1|Opts:Stem=Up
    |Note|Dur:4th|Pos:#-1|Opts:Stem=Up
    !NoteWorthyComposerClip-End
    ********** above for top window, rest for bottom ******
    !NoteWorthyComposerClip(2.5,Single)
    |Clef|Type:Treble
    |Note|Dur:4th|Pos:-2|Opts:Stem=Down
    |Note|Dur:4th|Pos:#-2|Opts:Stem=Down
    |Note|Dur:4th|Pos:-2|Opts:Stem=Down
    |Note|Dur:4th|Pos:#-2|Opts:Stem=Down
    !NoteWorthyComposerClip-End

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles