|
-
Jan 11th, 2005, 03:58 PM
#1
Thread Starter
Addicted Member
Regular Expression Construction Help[RESOLVED]
I'm using VBA for excel, and Im facing a problem.
I have a string, for example abcde
If the string (data in a cell) is as above, then its OK. Sometimes, the data recieved might have some apostrophes (") at the beginning or end. To capture this, I want to pattern match against every cell to account for the following strings
"abcde
abcde"
"abcde"
In all the above, the output shud be abcde. I found a lot of websites detailing out pattern matching for VB, but, I believe that its not the same for VBA for excel. For example..." are referred to as chr(34) as I recently dicovered.
If someone could help me build the regex im looking for...I'd really appreciate it!!
Last edited by perlmonk; Jan 13th, 2005 at 12:45 PM.
-
Jan 12th, 2005, 10:56 AM
#2
Re: Regular Expression Construction Help
 Originally Posted by perlmonk
I'm using VBA for excel, and Im facing a problem.
I have a string, for example abcde
If the string (data in a cell) is as above, then its OK. Sometimes, the data recieved might have some apostrophes (") at the beginning or end. To capture this, I want to pattern match against every cell to account for the following strings
"abcde
abcde"
"abcde"
In all the above, the output shud be abcde. I found a lot of websites detailing out pattern matching for VB, but, I believe that its not the same for VBA for excel. For example..." are referred to as chr(34) as I recently dicovered.
If someone could help me build the regex im looking for...I'd really appreciate it!!
If you need to refer to a (") character inside of a literal string surrounded by (") characters, you can use 2 (") back-to-back which will allow a single (") inside of a string:
VB Code:
"This has 2 ""quotes"" inside it."
-
Jan 12th, 2005, 12:07 PM
#3
Thread Starter
Addicted Member
Re: Regular Expression Construction Help
Thanks for the suggestion...I will try it right away...do you have any suggestion as to how to pattern match any character after the ("), whether integer or character?
-
Jan 12th, 2005, 12:18 PM
#4
Re: Regular Expression Construction Help
 Originally Posted by perlmonk
Thanks for the suggestion...I will try it right away...do you have any suggestion as to how to pattern match any character after the ("), whether integer or character?
Using pattern matching implies a formatted input as an input argument to either an operator (Like, +, etc..) or a named function.
Is this what you are doing? Please explain more.
-
Jan 12th, 2005, 12:25 PM
#5
Thread Starter
Addicted Member
Re: Regular Expression Construction Help
 Originally Posted by Dave Sell
Using pattern matching implies a formatted input as an input argument to either an operator (Like, +, etc..) or a named function.
Is this what you are doing? Please explain more.
The input will be in the form of some data in an excel cell. This alphanumeric data, for the most part would be formatted correctly (meaning that the data would be as is, without any quotation marks or anything)...but sometimes the data might have quotation marks in the beginning, end or both...for example, if abc represents the correctly formatted data..the incorrect formatted data might be "abc or abc" or "abc"
I want to trap these quotation marks, if present, and remove them.
I hope this explains my problem..please let me know!! Thanks a bunch
-
Jan 12th, 2005, 12:50 PM
#6
Thread Starter
Addicted Member
Re: Regular Expression Construction Help
do you think adding the following reference to my list of references would help?
Microsoft VBScript Regular Expressions 5.5...I found this in the References selection under tools.
Also, found more info on this at http://visualbasic.about.com/od/usin...l/blregexa.htm
-
Jan 12th, 2005, 02:51 PM
#7
Re: Regular Expression Construction Help
 Originally Posted by perlmonk
do you think adding the following reference to my list of references would help?
Microsoft VBScript Regular Expressions 5.5...I found this in the References selection under tools.
Also, found more info on this at http://visualbasic.about.com/od/usin...l/blregexa.htm
Probably, but I've never used it.
-
Jan 12th, 2005, 03:19 PM
#8
Thread Starter
Addicted Member
Re: Regular Expression Construction Help
yea...this didnt work...am pretty disappointed.
any suggestions??
-
Jan 12th, 2005, 03:28 PM
#9
Re: Regular Expression Construction Help
 Originally Posted by perlmonk
yea...this didnt work...am pretty disappointed.
any suggestions??
You just have to use your function.
-
Jan 12th, 2005, 04:10 PM
#10
Re: Regular Expression Construction Help
You may want to post a thread in the VB.NET forum since more users would
familiar with RegEx over there.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 12th, 2005, 04:34 PM
#11
Thread Starter
Addicted Member
Re: Regular Expression Construction Help
 Originally Posted by RobDog888
You may want to post a thread in the VB.NET forum since more users would
familiar with RegEx over there. 
Hey thanks everyone...I'll try the Instr function, but im sure there is a shorter way by using regex.
I'll post my prob in .NET section as well...thanks once again!!
-
Jan 13th, 2005, 12:45 PM
#12
Thread Starter
Addicted Member
Re: Regular Expression Construction Help
I fixed the issue using the replace function....sweeeeeeet .
thanks everyone
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|