Regex / Check For Preceding And Following Character
Jun 10, 2011
Sometimes when backing up an sql file using phpmyadmin (database stuff), for some reason it forgets to double up a single quote, resulting in an error when loading the sql file back into the database when required. A line in such an sql file looks like this;[code]As shown in the example, phpmyadmin did double up the quote in "you're" as it should, but it forgot to double up the one after "27", resulting in an error.As you can see it's like this (*value*, *'value'*, (and so on) but beforehand I can;
A) Never know how many values are in such a string
B) Can't simply split the values by "," because the value itself can hold a comma aswel.
It would be easy if every value was like this; *'value'* because then I could split by " ', ' " but that's not the case, and I also never know what location the values not enclosed in single quotes are. I also can't simply double up all single quotes in the entire string because then it will also double up the ones that are enclosing the values, resulting in an error during upload again.So yeah, what I need to get done is single out all the values with regex ($1, $2 etc.) and then string.replace single quotes in those values but *only* if said single quote is not preceeded or followed by another single quote, else it would become a tripple quote resulting in an error again.
View 1 Replies
ADVERTISEMENT
May 9, 2010
My form has a texbox where user enters an ID. IDmust be4 chracters in length andof the form: begins with either "E" or "e" and the next 3 chracters cannot be "all characters".
Example:
E102 - corect
e3ff - correct
[code].....
View 4 Replies
Feb 18, 2011
I can't get my sql query using regex to work in vb.net. If I write
Dim localConnection As New MySqlConnection = ConnectionNew(DBName)
Dim da as MysqlDataAdapter
Dim ds as new DataSet
Dim rows as long
[code]....
It returns null, even though there is a cell containing "ABC". When I run it directly on the database, it returns the row correctly.If I remove the [A-Z], it works fine in both circumstances.
View 1 Replies
Oct 27, 2011
I'm creating a calculator, and I need a way to get the numbers surrounded a character I provide.
For example:
Equation: 5+5*2/7
Character: *
Result: array(5, 2)
I was wondering if regex would be able to do this and if it can.
View 8 Replies
May 9, 2012
I have a form like this
And its code :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text.Contains(" ") Then
[Code].....
Now what code should I use when I click the button, if TextBox1 contains 2 SPACE characters, it will split into 3 parts, but if it contains only one SPACE, it'll split into 2 parts ?
View 5 Replies
Jul 18, 2011
I'd like to be able to match a specific sequence of characters, starting with a particular substring and ending with a particular substring. My positive lookahead regex works if there is only one instance to match on a line, but not if there should be multiple matches on a line. I understand this is because (.+) captures up everything until the last positive lookahead expression is found. It'd be nice if it would capture everything until the first expression is found.
Here is my regex attempt:
@@FOO[(.*)(?=~~)~~(.*)(?=]@@)]@@
Sample input:
@@FOO[abc~~hi]@@ @@FOO[def~~hey]@@
Desired output: 2 matches, with 2 matching groups each (abc, hi) and (def, hey).
Actual output: 1 match with 2 groups (abc~~hi]@@ @@FOO[def, hey)
Is there a way to get the desired output?
View 3 Replies
Dec 1, 2010
How do I make a regex that can detect a certain character string that is either all by its self in a line, or separated by white space.
If I have the line:
"ot"
Or the line
"sdf gdfg dv ewrsef fvdf ot sdfsd sdot"
I want to be able to detect the 'ot', except for the one that is 'sdot'
View 5 Replies
Jul 17, 2009
I am using a simple regular expression (in C#) to find a whole word within a block of text.
The word may appear at the beginning, end or in the middle of a the text or sentence with in the text.
The expression I have been using word has been working fine however if the word included a special character (that has been escaped) it no longer works. The boundary is essential so that we do not pick up words such as vb.net as a match for .net.[code]...
View 3 Replies
Aug 9, 2011
Given an input string like the following:I, Need, Some, Coffee, Before, I, "Fall, Asleep" I need to split this into parts like so:
I
Need
Some
[code]...
Splitting on the comma character alone is easy enough, but how can I handle the quotationmarks? Regular expressions is not on my strong side, and I have been googling for quite a bit without any good results.
View 14 Replies
Jul 20, 2009
I'm trying to replace all the carriage return characters in a string obtained from a multi line text box in a Windows Form with the string ", <BR>" so that when I use the string in some HTML it displays correctly.
Function Blah(ByVal strInput As String) As String
Dim rexCR As Object
rexCR = CreateObject("VBScript.RegExp")
[code]....
View 5 Replies
Aug 31, 2010
My Regex works, except if the email address entered has an underscore character (_) in it.
Because of my lack of experience with regular expressions, I'm not sure where in my pattern I'm supposed to add the offending character to allow it:
Dim pattern As String = "^[-a-zAZ0-9][-.a-zA-Z0-9]*@[-.a-zA-Z0-0]+(.[-.a-zA-Z0-0+)*." & _
"(com|edu|info|gov|int|mil|net|org|biz|name|museum|coop|aero|pro|tv|[a-zA-Z]{2})$"
He said he fixed it by adding the _ after the numeric check.
I see the A-Z0-9, but I'm not sure which is the numeric check...
View 2 Replies
Mar 5, 2010
I have a streamreader that is reading a file that has the possibility of having the contained information being separated by either a space, a semicolon or a comma, or even a page break.How can I check for all those things and then place them in a array?'I know this is the way to check for one character, how do I add on to this?
arrDataHolder = txtDocument.Split(CChar(","))
View 1 Replies
Jul 22, 2010
I need to check if a character is a valid Key (type) in VB.NET (I need to turn "K" into Keys.K, for example). I am currently doing this to convert it:
Keys.Parse(GetType(Keys), key, False)
View 2 Replies
Sep 22, 2009
I need to trim everything preceding the last / in a string. for example if the string were "C:FilesNewprogram.exe" all I want is the "program.exe portion.
View 3 Replies
Nov 5, 2010
How can I check if a StringBuilder contains a certain character or string? There is no Contains method like the string class has.
View 8 Replies
Mar 15, 2011
regex - regular expression to check input on multiline textbox
View 5 Replies
May 3, 2012
I need to use regex to check if the user add the numbers of phone in this 'Formula'
0911111111,0922222222,0933333333
must the number start with '09'
must the number contains '10' characters'
must the numbers seperated by Comaa ','
View 4 Replies
Sep 12, 2010
Im using HtmlAgilityPack/HAP so that I can use Xpath with HTML documents.selecting the preceding-sibling of div class="address" in this url[url].....The sibling that I want is h3 class="listingTitleLine" Here is a screenshot:
View 1 Replies
Jul 15, 2011
I am trying to check if a users input contains any special characters from a list, does anyone know who I would go about doing this?
I've tried the LIKE operator:
Dim sMatch As Boolean = tTitle.Text Like "[-/,.:;*?""""<>|&'[]^%£$()_+=!#]"
but doesn't seem to work, i think special characters are used for settings.
Is there a RegEx i could use for this??
View 2 Replies
Feb 10, 2012
How would I check a given string for the presence of any match with a character listed in another string. I'm just looking for a binary result.
In other words, how would I write the VB.NET function called IsPresent in the following code snippet?
Result = IsPresent(AnyString, MyTestString)
For example, if MyTestString = "XYZ" then I want the following results for the given AnyString values:
MUTTON, Result = No
BUZZ, Result = Yes
HAPPY, Result = Yes
FISH, Result = No
View 2 Replies
Feb 16, 2011
How to check the Single byte character (e.g. English) and Double bytes character(e.g. Chinese) ?
Since I want to printing out their code which are representing in Hex.
However, Single byte character is using 2 digits of Hex. And Double bytes character is using 4 digits of Hex.
So, how can I check them and output with more readable pattern ?
input likes: 微軟 Microsoft output likes: B74C B36E 4D 69 63 72 6F 73 6F 66 74
View 1 Replies
Nov 9, 2009
Is there a way I can check the place of the character in a line or string? For example: I want them to guess 1214 So how would I make sure each character is in the right place?
View 2 Replies
Jan 30, 2012
I'm working on a project which involves communications with a remote device via a modem. Communication is accomplished via HEX commands. However, with my code below, I am not receiving zeros where they are meant to be.For example, a test file contains the following HEX:
010203040506070809
However, I am only receiving this:
123456789
The zeros are critical.
Private Sub receive_data(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim buff As String
Dim i As Short
[code]....
View 3 Replies
Jan 21, 2011
I want to user to enter only numbers and characters in textbox i.e no special charaters.I don't want to use key press event of textbox.As i need same validation in gridview.
So i want to validate whole string.
View 2 Replies
Aug 20, 2011
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
View 2 Replies
Nov 22, 2009
I've been developing an export program which generate a csv file.
Column_A, Column_B, Column_C
00014, Sample, test
Now upon this data is viewed in csv the trailing zero from column_A is gone. it becomes 14.I revise the writing of data from Column_A which if the start of it is zero i insert a single quote. Upon viewing it in csv i got a '00014 which single quote is visible. how can i remove this single quote? which i expected to view it 00014 only in csv file.
View 9 Replies
Mar 15, 2009
We know that VB string start and end with double quotes " "
So we have to use "" if we want " in VB string.
I wonder if there is a regular expression pattern which will match VB string?.
View 2 Replies
Apr 5, 2012
I am having an issue where I am using regex.Replace to replace part of a string. The basic idea is that I want to capture the beginning of the string then replace the end of the string with a value from code. For an example pretend I have a string that says "Test Number " followed by number and I want to increment that number. I capture the "Test Number " but when I try to concatenate that capture with the new number it treats the capture ($1) as a literal and replaces the entire string with $1[new number].
[code]...
This will output "We are on Test Number 2", as expected. how I can use a variable in the replacement string portion of the Regex.Replace when including a captured group?
View 1 Replies
Mar 9, 2010
Is an implicit declaration basically an explicit declaration without the "Dim" statement preceding it?
View 12 Replies
Aug 4, 2009
I need to know the proper way, or maybe I should say, the different ways to call another form from a parent or preceding form. I am currently using ex: formname.showdialog() to call my next form, but I am uncertain if I should be using that in every situation. [code] Whats the difference between these different methods? (ex: .showdialog() , .show() )I tried both of these to open a temporary form to retrieve a persons name from a database, so as the users progresses through my training program they can keep track of their scores.But, I also call other forms as I branch through my program, from the main page, to a secondary page, to a testing page, to a results page and then back to the secondary page
View 5 Replies