I need to replace all occurancies of "is" in "This is a test (is), is,
penis." with "<a href=is.htm>is</a>".
The thing is, if I use a simple Replace function, the "is" in penis
also gets replaced.
I need to do it either in ASP/VBS or MSSQL, but I'd have it rather
done in ASP.
TIA 8 6230
replace " is " instead of "is"
--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software http://www.Darkfalz.com
---------------------------------------------------------
...Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"Pret Orian" <pr**********@yahoo.com> wrote in message
news:98**************************@posting.google.c om... I need to replace all occurancies of "is" in "This is a test (is), is, penis." with "<a href=is.htm>is</a>". The thing is, if I use a simple Replace function, the "is" in penis also gets replaced. I need to do it either in ASP/VBS or MSSQL, but I'd have it rather done in ASP. TIA
Pret Orian wrote: I need to replace all occurancies of "is" in "This is a test (is), is, penis." with "<a href=is.htm>is</a>". The thing is, if I use a simple Replace function, the "is" in penis also gets replaced. I need to do it either in ASP/VBS or MSSQL, but I'd have it rather done in ASP. TIA
s1 = "This is his test (is), is, is."
with new regexp
.global = true
.ignorecase = true
.pattern = "\bis\b"
s2 = .replace(s1,"<a href=is.htm>is</a>")
end with
msgbox s1 & vbcrlf & s2
--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
Technet Script Center http://www.microsoft.com/technet/scr...er/default.asp
Microsoft® Windows®2000 Scripting Guide http://www.microsoft.com/technet/scr...s_overview.asp pr**********@yahoo.com (Pret Orian) wrote in message news:<98**************************@posting.google. com>... I need to replace all occurancies of "is" in "This is a test (is), is, penis." with "<a href=is.htm>is</a>". The thing is, if I use a simple Replace function, the "is" in penis also gets replaced. I need to do it either in ASP/VBS or MSSQL, but I'd have it rather done in ASP. TIA
I'm afraid I didn't explain my problem god enough.
I want to replace "is" only if it is not a part of another word, so
something like [^a-zA-Z]is[^a-zA-Z] pattern. "(is)", "is," should all
be positive matches, and "penis" should not.
"Pret Orian" <pr**********@yahoo.com> wrote in message
news:98**************************@posting.google.c om... I'm afraid I didn't explain my problem god enough. I want to replace "is" only if it is not a part of another word, so something like [^a-zA-Z]is[^a-zA-Z] pattern. "(is)", "is," should all be positive matches, and "penis" should not.
Did you try Michael Harris' script? (He politely uses "his" in his example
to demonstrate.)
Joe Earnest
>Did you try Michael Harris' script? (He politely uses "his" in his
example to demonstrate.)
I did try the Michael's script and it did work indeed (thanx Michael).
However, I'm having a problem with "is" word standing on the beginning
of the string (or at the end). What would be a pattern that would
exclude all the characters that are not a-zA-Z except if beeing on the
beginning of the string
For example:
..pattern = "\bis\b"
Replaces: "this is something" "(is)" " This is." ...
But leaves "is this something" untouched.
Is there a way out?
Where are the escape characters (like \b) documented?
regards
Hi,
"Pret Orian" <pr**********@yahoo.com> wrote in message
news:98**************************@posting.google.c om... I did try the Michael's script and it did work indeed (thanx Michael). However, I'm having a problem with "is" word standing on the beginning of the string (or at the end). What would be a pattern that would exclude all the characters that are not a-zA-Z except if beeing on the beginning of the string For example:
.pattern = "\bis\b"
Replaces: "this is something" "(is)" " This is." ... But leaves "is this something" untouched.
Is there a way out? Where are the escape characters (like \b) documented? regards
I'm not much at regex, and maybe some one can post a simple regex addition,
but as a fallback, you could do the beginning and end issues with standard
string manipulation, after using Michael's regex script. It's kludgy, but
it works.
s1= "is this something? it is, it is"
' Michael's regex script
with new regexp
.global = true
.ignorecase = true
.pattern = "\bis\b"
s2 = .replace(s1,"<a href=is.htm>is</a>")
end with
'add
if lcase(left(s2 & " ", 3)="is ") then _
s2= "<a href=is.htm>is</a>" & mid(s2, 3)
if lcase(right(s2, 3)=" is") then _
s2= left(s2, len(s2) -2) & "<a href=is.htm>is</a>"
msgbox s1 & vbcrlf & s2
Joe Earnest
Pret Orian wrote: Did you try Michael Harris' script? (He politely uses "his" in his example to demonstrate.)
I did try the Michael's script and it did work indeed (thanx Michael). However, I'm having a problem with "is" word standing on the beginning of the string (or at the end). What would be a pattern that would exclude all the characters that are not a-zA-Z except if beeing on the beginning of the string
s1 = "Is this what his is_test is? - Is IS iS - yes, it is"
with new regexp
.global = true
.ignorecase = true
.pattern = "\W(is)\W"
s2 = .replace(s1,"<a href=is.htm>is</a>")
end with
msgbox s1 & vbcrlf & s2
--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
Technet Script Center http://www.microsoft.com/technet/scr...er/default.asp
Microsoft® Windows®2000 Scripting Guide http://www.microsoft.com/technet/scr...s_overview.asp
"Michael Harris (MVP)" <mi****@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... What I actually meant was this...notice the $1 in the replacement
string to use the text that was matched in the replacement text...
s1 = "Is this what his is_test is? - Is IS iS - yes, it is" with new regexp .global = true .ignorecase = true .pattern = "\W(is)\W" s2 = .replace(s1,"<a href=is.htm>$1</a>") end with
msgbox s1 & vbcrlf & s2
-- Michael Harris Microsoft.MVP.Scripting Seattle WA US
Technet Script Center http://www.microsoft.com/technet/scr...er/default.asp
Microsoft® Windows®2000 Scripting Guide http://www.microsoft.com/technet/scr...s_overview.asp
Michael, your code consumes the surrounding "non-word" characters.
Here's some code based on the OP's original pattern
"[^a-zA-Z]is[^a-zA-Z]". I reduced the range since ignore case was in
effect.
<script language="VBScript" runat="SERVER">
str = "Is this what his is_test is? - Is IS iS - yes, it is"
with new regexp
.global = true
.ignorecase = true
.pattern = "([^a-z])(is)([^a-z])"
Response.Write "<br>vbscript : " & .replace(str,"$1<a
href=is.htm>$2</a>$3")
end with
</script>
<script language="JScript" runat="SERVER">
Response.Write("<br>JScript: " + "Is this what his is_test is? - Is IS
iS - yes, it is".replace(/([^a-z])(is)([^a-z])/gi,"$1<a
href=is.htm>$2</a>$3"));
</script>
For the OP, here are links to regular expression syntax in VBScript and
JScript respectively: http://msdn.microsoft.com/library/en...propattern.asp http://msdn.microsoft.com/library/en...gexpsyntax.asp This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Craig Keightley |
last post by:
Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)
BEGIN CODE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Update...
|
by: Barnes |
last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form?
Here is the scenario:
I have a form that cannot accept apostrophes. I want to use the replace() so...
|
by: Danny |
last post by:
I need an asp command to strip out from a string all extra punctuation such
as apostrophe, comma, period, spaces dashes, etc etc and just leave the
letters.
Can anybody give me some ideas?
...
|
by: Peter Row |
last post by:
Hi,
I know this has been asked before, but reading the threads it is still not
entirely clear.
Deciding which .Replace( ) to use when.
Typically if I create a string in a loop I always use a...
|
by: Cor |
last post by:
Hi Newsgroup,
I have given an answer in this newsgroup about a "Replace".
There came an answer on that I did not understand, so I have done some
tests.
I got the idea that someone said,...
|
by: Goran Djuranovic |
last post by:
Hi all,
I ran into a problem where my XMLTextReader fails on .Read() when I have "<" character in one of the attribute's values. What I am trying to do is replace illegal characters ("<", "&" ,...
|
by: TOXiC |
last post by:
Hi everyone,
First I say that I serched and tryed everything but I cannot figure
out how I can do it.
I want to open a a file (not necessary a txt) and find and replace a
string.
I can do it...
|
by: JackpipE |
last post by:
Here is my replace query and I need to run this on every column in my
table. Right now I manually enter the column name (_LANGUAGES_SPOKEN)
but this is time consuming and would like to automate...
|
by: V S Rawat |
last post by:
I was trying to use back-to-back replace functions to convert a url:
str1 =
str.replace("%2F","/").replace("%3F","?").replace("%3D","=").replace("%2
6","&");
It didn't replace all 4 types of...
|
by: =?Utf-8?B?TWlrZSAiWU9fQkVFIiBC?= |
last post by:
I have a text file that contains about 8 to 10 text sequences that I need to
replace.
I want to search and replace all 8 to 10 text sequence anytime I run this
script
Here is what I have so...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
| |