Regular Expression :: Split By Comma (CSV File)
I have a sting that have to be split by comma (cvs file)
Let me give you an example:
this is my string:
asd,asd,asd,"asd,asd,asd",asd,asd
I have to split this string but the string that is in quote I dont whant to be splited
result have to be like that:
Array(
[0]=>asd
[1]=>asd
[2]=>asd
[3]=>"asd,asd,asd"
[4]=>asd
[5]=>asd
)
View Replies
ADVERTISEMENT
I am trying to execute the following SQL Statement:
SqlApp1 = "INSERT INTO LeagueStore (Team, Played, Wins, Loses, Draws, For, Against, Points) SELECT (Team, Played, Wins, Loses, Draws, For, Against, Points) from HomeWins WHERE postponed=''"
But i am getting the following error message:
Syntax error (comma) in query expression '(Team, Played, Wins, Loses, Draws, For, Against, Points)'.
And i dont know why. All of the fields are numerical apart from TEAM is that helps.
All i want to do is Insert data from one table into another but i cant use SELECT * because one table has one extra field to the other and when i tried to amend the SQL to look like this:
SqlApp1 = "INSERT INTO LeagueStore (Team, Played, Wins, Loses, Draws, For, Against, Points) SELECT * from HomeWins WHERE postponed=''"
i get this error:
Number of query values and destination fields are not the same
View Replies
View Related
Can anyone give me a regular expression for finding a URL in a string of
text?
Essentially what I want to do is find URLs in a text string and embed
them in {a href...} tags. However, I haven't used regular expressions
all that much in ASP/VBSCRIPT.
View Replies
View Related
I need to create a regular expression for a date field that works only
in the following format MM/DD/YYYY with the / in the format. No other
format can be inputted into the field. I need 2 numbers for MM 2
Numbers for DD and 4 numbers for YYYY. If the users enter 1 number for
month, 1 for day he should get an alert.
I have this code and thought it was working but it is not.
var RegExPattern = /(d{1,2})W(d{1,2})W(d{4})/;
View Replies
View Related
i know there are tutorials for Regular Expressions too, but can a 'simple' example be posted in these forms
View Replies
View Related
I'm going down the road of learing the pattern matching in regular
expressions, and I'm trying to convert the characters into English in my
head so I can see whats happening...
For clarity with this one...
[b]([^]]+)[/b]
Ok - the first thing I did was break it up - because it looks a nightmare
like that...so now I have..3 parts..
[b]
([^]]+)
[/b]
In part 1 I under stand that the is telling the expression that a special
character is coming next, thus escaping the [ and ] respectively, thus ,
and in part 3 I understand the same and also the escaping of the /, thus
- no problems so far...
In part 2 I'm assuming that the brackets are seperating a "pattern" so that
I might reference it as $1 later on, I understand that the [^] are saying
"not enclosed" so therefore it's going to ignore a ], the + sign however
perplexes me - my VBScript book says "Matches the preceeding character one
or more times" - so does that mean the ] just before it, or does it mean the
character OR characters defined within the [ ] etc?
View Replies
View Related
looking for a regular expression example for asp in vbscript. just want to search for a name in some text, possibly display that text.
View Replies
View Related
I'm trying to find a regular expression function to strip contents out of a string which lie between square brackets [].I've got one for chevrons (to remove HTML - as below), but would prefer not to have to replace the chevrons for square brackets first.Code:
function funRemoveHTML( strText )
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
funRemoveHTML = RegEx.Replace(strText, "")
end function
how I can modify this for square brackets as opposed to chevrons?
View Replies
View Related
I am working on an ASP page which looks in a set of text for web page URLs.
Using the VBScript.RegExp regular expression object, I have this regular
expression:
[a-z]+.[a-z]+.[a-z]+/
And it works well finding URL's such as: windowsupdate.microsoft.com,
www.cnn.com, etc.
However, I have been trying to modify it to ALSO find URL's like this:
www.amazon.com/index/sell/ie6.html?val=1
Or
www.microsoft.com/windowsxp
Any ideas?
View Replies
View Related
I'm making url's out of text starting with "www" etc. but I've got two problems. Firstly, if the string begins with www it doesn't get matched, and secondly, if there's a dot or a comma directly after the url, it becomes part of the url. I hope someone who is better at this than me will be able to help me out. Code:
reg.Pattern = "(s)(www)(S)(S+)"
s = reg.Replace(s, "$1<a href=""http://$2$3$4"" target=""_blank"">$2$3$4</a>")
View Replies
View Related
I have been using a regular expression that I don’t uite understand to
filter the valid email address. My regular expression is as follows:
<asp:RegularExpressionValidator id="valValidEmail"
runat="server"
ControlToValidate="txtEmail"
ValidationExpression="^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})$"
ErrorMessage="Invalid Email address."
Display="None">
</asp:RegularExpressionValidator>
Can someone explain me why the email address Join Bytes! is
considered an invalid email address?
Also can someone explain me what the above regular expression means?
View Replies
View Related
I need to parse the following:
aaa_bbb_d_yyyy_mm.ext
aaa = ITM, CPF, FAC, GEN
bbb = almost anything (even more then 3 chars)
d = M,Q,Y,R
yyyy = year
mm = month
I'm terrible at figuring out regexp so I turn to the kind folk of SP
View Replies
View Related
I have a field that should take a date in the following two formats:
MM/DD/YYYY or MM/DD (and assume it is this year, it will fill in current year)
I have my program checking against two regular expressions. The first one is ok:
Dim regEx
Set regEx = New RegEx
regEx.Pattern = "^(([1-9])|10|11|12)/(([1-9])|((1|2)[0-9])|30|31)/200[0-9]"
If the date checked comes up False, it then goes to this expression:
regEx.Pattern = "^((0[1-9])|(10|11|12))/((0[1-9])|((1|2)[0-9])|30|31)"
My problem is on the second one. If I enter an erroneous date like this: 11/189
It will go through and crash my program.
View Replies
View Related
I am using regular expression to replace the text, This is asp function I have used to replace the text, but it’s not working properly Code:
View Replies
View Related
addContent = replace(addContent,"<font>","")
Right, pretty simple eh!
However, what I need is something to say replace all occurence of strings that start with "<font" to eb replaced by zilch i.e.
<font>
<font color=green>
<font tag=this another=more>
I believe regular expression are the way to go?
View Replies
View Related
any one have a quick regex for making sure that only 0..9 a..f are in a string?
View Replies
View Related
I'm trying to return a sub string using the regular expression object. I've not really used the regular expression object before and I'm finding it a bit clunky to use.
Basically I'm trying to match the 'description' within the string 'file_description_1'
However I'm unsure how to return the partial, would I use the Execute or Replace methods?
Regex looks like this:
With RegularExpressionObject
.Pattern = "file_(.*?)_[0-9]"
.IgnoreCase = False
.Global = True
End With
View Replies
View Related
I've discovered an insidious bug with the VBScript Regular Expression
object.I set the pattern to consist of the set of invalid filename
characters plus comma. I set global property to true then do a replace on a
SID. The Replace does nothing. However, if I attach the C++ (dev studio
2003) debugger to the IIS host process (dllhost.exe), every time I call
RegExp.Replace, the stack for one of the process's threads gets scrambled.
It ends up with the value 0x00000001 at the top of the stack! If your
debugger is set to stop on access violations, it always catches one (invalid
read trying to delete). The problem is insidious because, without the
debugger running, you would never know this is happening. ASP returns no
error. Potentially this could wreak havoc on your web application and cause
bizarre failures later on. Has anyone else run into this one? It seems to
happen only with the Replace method.
View Replies
View Related
I need a regex pattern that will grab a select or textarea tag in an HTML file. If I run
the pattern I should get:
<select name="whatever">
<option value="a" selected>A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
Or
<textarea name="whatever">Here is some text area text</textarea>
I know the following pattern works:
<(select|textarea).*(.|
)*?</(select|textarea)>
But the problem is my web hosting company is using ASP scripting engine 5.1 which does not support the non greedy delimiter (?). I doubt they are going to upgrade to 5.5 anytime soon.
I'll appreciate it if anyone can give me a pattern that does the same job but does not use the ? delimiter. Is there a way I can tweak the pattern above so that it works in ASP scripting engine 5.1?
View Replies
View Related
I'm trying to work out a reg.exp. that will pick out a sql statement against a certain set of tables - in this case any table named "Survey~something~", but I only want to pull back those statements where the CompanyID column doesn't appear in the query. (The expression is being used in my editor so it might appear a little strange, but by and large it works the same as you'd expect.)
[^']select(.){0,100}from(.){0,100}Survey(.){0,25}where (.){0,200}
What do I need to add so that I get those without a companyid column?
Something like...
[^']select(.){0,100}from(.){0,100}Survey(.){0,25}where (.){0,200}(^companyid)
(tried this one, but it doesn't work)
View Replies
View Related
I have a search results page that lists a series of records with clickable links to view the records. When you click on the link to the record, the record id, the search terms used, and the search type (exactphrase or anywords) is sent through the query string.
On the record page I have been trying to find a regular expression that would find and replace the search terms with < strong >< /strong > to highlight them. I am struggling.
Does any use a similar regular expression. One that, if flagged, will replace an exact string (phrase) or loop through an array replacing any of the words in the string?
View Replies
View Related
here is a pattern I am using in regexp module:
href(.*?)[x22>][^x22]*x22
This string seems to work in that it will return
href = "http://www.domain.com"
from href tags such as this.
<a href = "http://www.domain.com">This is a link</a>
it handles the spaces that may exist before and after equal sign. (basically I am trying to extract links out of my url)
is there a way I can take this pattern a bit further to return just the http://www.domain.com
I am new to regexp but have managed to get this far.
View Replies
View Related
I'm trying to write a function to return submatches. I want to do this because I want to run a match on matches of matches of yet other matches, so it seemed to me it would be easier to work with if there was one line of code that would return a collection or array of matches. Here's what I got:
<%
Dim objRegExp
Set objRegExp = New RegExp
Dim objMatches, objMatch
Set submatches = getsubmatches("this should hopefully match and print
eight words", "(w)", TRUE, TRUE)
For i = 0 To submatches.Count - 1
response.write "<br>" & submatches(i)
Next
Function getsubmatches(strText, pattern, isGlobal, ignoreCase)
Dim data
'Set our pattern
objRegExp.Pattern = pattern
objRegExp.IgnoreCase = ignoreCase
objRegExp.Global = isGlobal
For Each objMatch in objRegExp.Execute(strText)
getsubmatches = objMatch.SubMatches
Next
End Function
%>
I get:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment
/getsubmatches.asp, line 22
thats this line: "getsubmatches = objMatch.SubMatches"
Can anyone help me write this correctly?
View Replies
View Related
eg: AAA, BBB, CCC (3 items) in the lists.
i would like to remove BBB and make it become AAA, CCC
anyone know how i can do it in regular expression?
it is possible to remove 1st, or 3rd items. but only all items inside is identical. and only remove single item.
View Replies
View Related
If I want my phone number like this...
(XXX)XXX-XXXX
([0-9]{3})[0-9]{3}-[0-9]{4} ....
View Replies
View Related
I'm back with something that makes no sense to me .... as far as I can see the three if statements are identical except for the input. One is the regular phone, then cell phone and then the fax .....
View Replies
View Related
I need help with a regular expression. Here are the rules I need to apply:
Exactly 8 characters
Alphanumeric only (no punctuation at all)
Must have only one numeric (1 is not allowed)
Must start and end with an alpha
I'm doing the length check with a len, so it's not a big deal if it's added in there or not. I have most of it working, but the one that's biting me in the backside is the one numeric check. I thought it would be a simple matter of using: Regex.Pattern = "^[A-Za-z]+d+[A-Za-z]$". However if I use this, I get: ...
View Replies
View Related
Been pounding on this for an hour and eating up my day's productivity, so I thought I'd throw a question out there. (I'm also reading through the Google archives to try to find this answer...)
Windows 2000 Small Business Server
Using regular expressions for the first time, and having difficulty with the replace method. We're searching through a list of vehicle models, trying to replace what we get from the client data with correctly propercased text...ie..we get FORD F150 and replace it with Ford F150; CHEVROLET ES 300 and replace it with Chrevrolet ES 300; ACURA MDX >> Acura MDX. The usual propercase algorithms don't work because of the multiple capitals in some of the model names: we don't want Acura Mdx.
The test method always works. The problem we're having is that, under certain circumstances, the replace method is replacing too much. We've created a table of capitals as they relate to models: ES; MDX; XL; SL; and so on. The pattern we're using is this: ....
View Replies
View Related
I am new to reg expressions and would like to write a regex for a .html page I am working. I want the regex to find every http link (<a href= ) that contains .org. Once it finds every link that contains .org I want to then remove ( exit.asp?url= ) that precedes it as well as add the attribute ( target="_blank" ) to the (<a href=) tag.
This basically will find all instances where I am calling my .asp page that lets the user know they are exiting the main site for an outside source and eliminate this page as long as the link they are clicking is within the original site. Otherwise I call my exit.asp page which notifies the user they are leaving.
Example:
Look for this type of tag (one where the link contains .org):
<a href="exit.asp?url=http://myorgwebsite.org/myorg"> Link 1</a>
Replace with this (removes the "exit.asp?url=", but adds target="_blank" attribute):
<a href="http://myorgwebsite.org/myorg" target="_blank"> Link 1</a>
View Replies
View Related
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.
View Replies
View Related
I have created a search engine for my project but i need to be able to exclude obvious words from being searched.
E.g
Forums
FoRuMs
FORUMS
forumS
View Replies
View Related
I want to search a string of HTML and insert a querystring into any url where the url is an asp page and is either a local link /folder/page.asp or of a specific domain http://www.somedomain.com/folder/page.asp. It needs to be able to handle plain links and those with querystrings already in there.
I could do it with instr functions etc but I thought this might a good time to brush up on regular expressions. Can anyone point me in the right dirction?
View Replies
View Related
I have some asp code in variable so i want to rewrite anchor tags like this:
If i have:
<a href="http://www.sitepoint.com">www.sitepoint.com</a>
To be rewrited as:
<a href="http://www.sitepoint.com" target="_blank">www.sitepoint.com</a> out
The problem is that urls from my domain shouldn't be changed for example if href="/some_path" or href="http://www.mysite.com/some_path"
I try making some expressions with RegexBuddy but it didnt worked very nice.
View Replies
View Related