[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Regex Example needed.

Posted on 2005-04-15
12
Medium Priority
?
173 Views
Last Modified: 2010-04-23
I am looking for a sample regex that will return success if there are 61 characters in a string
(all printable characters can be present)
0
Comment
Question by:addicktz
  • 8
  • 4
12 Comments
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796369
is that to say that... you could have a string of lengrg ... 253... but you want to find if there are 61 characters in it?
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796372
length ...  sorry,  haven't been awake that long
0
 
LVL 1

Author Comment

by:addicktz
ID: 13796382
erm, im trying to identify UUencode which comes in lines of 61 characters

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796384
not heard of that before... you got a reference to what sort of pattern they come in?
0
 
LVL 1

Author Comment

by:addicktz
ID: 13796401
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796422
ok... so my understanding it a valid line is:

Begins with M
Has 61 characters
No white space (no spaces, tabs, new lines)
0
 
LVL 1

Author Comment

by:addicktz
ID: 13796430
that sounds about right
0
 
LVL 12

Accepted Solution

by:
S-Twilley earned 2000 total points
ID: 13796438
Dim regTest as new Regex("^M[^\s]{60}$")        ' character M (assuming it has to be uppercase)... followed by 60 non-whitespace chars... without any padding

Dim thisMatch As Match = regTest.Match(myString)

If thisMatch.Success Then
     Msgbox("Is Valid")
Else
     Msgbox("Invalid")
End If

============================

or this, one... it'll grab all phrases out from a string which has padding:

Dim regTest as new Regex("M[^\s]{60}")        ' character M (assuming it has to be uppercase)... followed by 60 non-whitespace chars...
Dim thisMatch As Match
Dim allMatches As MatchCollection = regTest.Matches(myString)

For Each thisMatch In allMatches
    MsgBox(thisMatch.Value)
Next
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796443
The first example... will gives these results:

"MRW9GI/Y)^;[FSDGO]3M-*C1^$K-!'-;JE'.(ET9H(E(G_=:LWVLJJ_W,_P'Y"         => Valid
"      MRW9GI/Y)^;[FSDGO]3M-*C1^$K-!'-;JE'.(ET9H(E(G_=:LWVLJJ_W,_P'Y"   => Invalid

================================

The second one :


"   MRW9GI/Y)^;[FSDGO]3M-*C1^$K-!'-;JE'.(ET9H(E(G_=:LWVLJJ_W,_P'Y          M_P!DW\4AS-*S_D]Z]V(;#S?H)I0VTH%[*MM1+,'X2S\;AA]BO'DWI.O+]ZOV  "

will give you:
msg1 -> MRW9GI/Y)^;[FSDGO]3M-*C1^$K-!'-;JE'.(ET9H(E(G_=:LWVLJJ_W,_P'Y
msg2 -> M_P!DW\4AS-*S_D]Z]V(;#S?H)I0VTH%[*MM1+,'X2S\;AA]BO'DWI.O+]ZOV

===================

I hope :P
0
 
LVL 1

Author Comment

by:addicktz
ID: 13796454
quick question, do you think i should be decoding as i download them or should i download them write them to a file then decode them?
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796461
think it's really a matter of urgency... downloading to a file and then decoding is probably "safer"... and you wont have to deal with waitin for a chunk to complete an incomplete chunk that you have

if you really want to decode as you receive data... it's possible, just you keep having to hold a buffer on the side when you have an incomplete line, then append  the incoming data to that side buffer, and test whether its a complete line yet
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796462
the latter is a bit more complicated... not alot... but a bit
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month19 days, 9 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question