Hi all,
I'm having a problem with a reg ex. Essentiall, I'm trying to isolate
variable declarations from old vbscript where there was no explicit
declaration requirement. This should seem easy enough - just identify by the
assignment statement; except for the fact that vb uses a single '=' token for
comparison as well as assignment. Therefore, I need a regex that will match
assignment statements while excluding if statements.
I tried to do the following:
(?!if)\s*(\w+)\ s*=\s*.*
but this statement matches both conditionals and assignments. Basically, I
need the following conditions to hold:
var="var" -> match
if var="var" -> no match
tia,
_howard 1 1746
> (?!if)\s*(\w+)\ s*=\s*.*
You're using lookahead ?!, but should use lookback ?<!.
Try this:
(?<!if\s*)(\w+) \s*=
Took the liberty to skip the \s*.* at then end because it doesn't do
anything :-)
By the way, if there are more assignments, this regex would catch them all:
a = 1
a = a + 1
The second statement would also be changed into a declaration, which isn't
right, but the compiler will tell you about it.
Take a look at http://regex.osherove.com/, by the way, it's insanely
useful for regex testing.
Greetings,
Wessel This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dean H. Saxe |
last post by:
I'm currently developing a tool in perl to search out potential XSS
(Cross Site Scripting) vulnerabilities and correct them in a
ColdFusion based web app. I've been having great success so far,
however, one scenario has me banging my head against the wall.
I need a regex to find all <cfoutput ...>...</cfoutput> blocks in a
CFM template. The regex should find all such blocks that are *not*
nested within HTML tags (the tag itself,...
|
by: alphatan |
last post by:
Is there relative source or document for this purpose?
I've searched the index of "Mastering Regular Expression", but cannot
get the useful information for C.
Thanks in advanced.
--
Learning is to improve, but not to prove.
|
by: Daniel Billingsley |
last post by:
First, if MSFT is listening I'll say IMO the MSDN material is sorely lacking
in this area... it's just a whole bunch of information thrown at you and
you're left to yourself as to organizing it in your head. Typical learning
starts with basics and progresses through increasingly complex information -
I think given the inherent confusion-inducing ability of regex that kind of
documentation would be very valuable.
But anyway, I'm trying...
|
by: Lee Kuhn |
last post by:
Is there a way to add a literal character to a regex match? For example,
normally applying the regex ..$ to the string "123456" results in a match
"56". I want to be to add a literal character to the beginning of the
resultant match string. In other words, is there a regex that could be
applied to the string "123456" to a get a match string "056"?
Thanks.
|
by: clintonG |
last post by:
I'm using an .aspx tool I found at but as nice as the interface is I
think I need to consider using others. Some can generate C# I understand.
Your preferences please...
<%= Clinton Gallagher
http://forta.com/books/0672325667/
| |
by: Bob |
last post by:
I need to create a Regex to extract all strings (including quotations) from
a C# or C++ source file. After being unsuccessful myself, I found this
sample on the internet:
@"@?""""|@?"".*?(?!\\).""|''|'.*?(?!\\).'"
I am inputting the entire source file string and using it with
RegexOptions.Singleline. This works OK with, unless the string ends with a
back-slash. For example: "This is a test\\". Can anybody see how to fix
this...
|
by: Jake Barnes |
last post by:
This function has always worked for me just fine:
function nl2br_js(myString){
// 02-18-06 - this function imitates the PHP command nl2br, which
finds newlines in a string
// and replaces them with newlines plus HTML BR tags. Is the easiest
way to create the
// appearance of paragraphs when people are creating web pages by
typing text into a form.
var regXString = "\\n"
|
by: CB |
last post by:
Trying to match the entire following object literal code using a RegEx.
var Punctuators = { '{' : 'LeftCurly', '}' : 'RightCurly' }
Variations on the idea of using /var.*{.*}/ of course stops at the
first }. Any ideas?
Thanks in advance.
|
by: voxiac |
last post by:
Could someone tell me why:
Fails with message:
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
re.compile('\\dir\\(file)')
File "C:\Python25\lib\re.py", line 180, in compile
return _compile(pattern, flags)
File "C:\Python25\lib\re.py", line 233, in _compile
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |