Finding A Matching And Replacing The Value?
Oct 21, 2009
i have 2 groups of text in my text file
Bottom
11.0 28 Red (2 13.10 04.0) [1 16.71 33.3] 130611 2948 229111 28275
6.5 28 Blue (2 03.00 03.0) [1 05.36 58.3] 132111 -67725 191611 -51225
2.0 28 Blue (1 05.36 45.3) [1 05.36 58.3] 211111 51225 210454 34691
[Code].....
View 14 Replies
ADVERTISEMENT
Jun 5, 2011
I am using vb.net to parse my own basic scripting language, sample below. I am a bit stuck trying to deal with the 2 separate types of nested brackets.
Assuming name = Sam
Assuming timeFormat = hh:mm:ss
Assuming time() is a function that takes a format string but
has a default value and returns a string.
[code]....
I could in theory change the syntax of the script completely but I would rather not. It is designed like this to enable strings without quotes because it will be included in an XML file and quotes in that context were getting messy and very prone to errors and readability issues. If this fails I could redesign using something other than quotes to mark out strings but I would rather use this method.
Preferably, unless there is some other way I am not aware of, I would like to do this using regex. I am aware that the standard regex is not really capable of this but I believe this is possible using MatchEvaluators in vb.net and some form of recursion based replacing. However I have not been able to get my head around it for the last day or so, possibly because it is hugely difficult, possibly because I am ill, or possibly because I am plain thick. I do have the following regex for parts of it.
Detecting the parentheses: (w*?)((.*?))(?=[^(+)]*((|$))
Detecting the square brackets: [[(.*?)]](?=[^[+]]*([[|$))
View 2 Replies
Aug 8, 2010
I am working on a program and for one of my features, I need to replace all spaces in a program with - (dashes.) Is there a way in which I can do this?
Example:
Start String = "The rain in Spain falls mainly in the plain."
End String = "The-rain-in-Spain-falls-mainly-in-the-plain."
[code].....
View 1 Replies
Jan 18, 2010
I currently have a very long column (5,000+) of which a lot of cells start with a range of zeros which I want to get rid of (the zero's that is). After importing the data from a txt file, I have a loop going through each row in turn getting data from different cells. So I could amend when teh data is being imported or during the loop reading the data.
[Code]...
View 3 Replies
Jan 27, 2009
I've got a string which could or could not contain the substring "/announce". I would like to replace this part of the string with "/scrape" if its found...so far nothing tricky. But heres the thing: I only want to replace it if the '/' in it is the last occurring in the string. Heres what I mean:
Heres a scenario where I want the replace to happen:
MyStringWithRandomText/announce?x=19
would become:
MyStringWithRandomText/scrape?x=19
And heres another scenario where the '/' in announce is not the last '/' occuring in the string, so I dont want to replace it:
MyStringWithRandomText/announce/foo?x=19
I hope that made sense. Not sure if there is a way to handle this by only using RegEx
View 2 Replies
Jul 6, 2011
I have a list of names of players and their names in some game. Now an administrator of that game might want to contact one of the players by sending him a message. He does that by writing a command that basically has the format "tell <player> <message>", where <player> is the name of the player.The problem is simple: player names might be quite complicated and long (it's their screen name not their real name), and it would take the admin quite some time to find out how to spell the name exactly and he will probably make a few mistakes. Basically, having the admin type out the exact name is not practical.So I am trying to implement a 'fuzzy logic' search (is that even the correct term?) but with a twist, I guess.The idea is that the admin can type just part of the name and is even allowed to make a couple mistakes. For example, suppose a player has a screen name of "Mr.Smith34", then the admin should be able to type, for example.[code]
The problem now is that there can be absolutely no ambiguity in which player is meant. Instead of sending a message (which is quite harmless) the admin should also be able to 'kick' or ban someone from a game server, banning them from ever playing there again. Obviously, the admin should then not accidently ban a player named "Mrs.Smith" when he meant "Mr.Smith"! My solution (unless someone else can come up with something better) is to just not allow the command if there are multiple matches. If the admin searches for 'smith' and there are multiple names that are similar to 'smith' (maybe even 'sith' or similar) then I disregard that search and tell the admin he needs to try again with a more specific name.(If all else fails he can always look up the ID of the player and use that, which should be foolproof as long as the admin doesn't make a mistake and picks the wrong ID..., but that is even more work it does not have preference).But this brings further problems. The example I just gave might be good: suppose there's a player "Mr.Smith" and a player "Sith". If the admin searches for 'Smith' then there should be no question who he meant (Mr.Smith), but I am sure any fuzzy logic implementation would count Sith as a very close match... Another thing is that my solution of only allowing the search if there is just a single match probably wouldn't work. I have never used fuzzy logic searching before, but I can imagine some names being marked as 'slightly similar' even when they are completely different ('smi' might match 'smith', but also 'ims' perhaps, in which case it would possibly match a whole new range of names), even though 'for humans' it is clear which result is meant.
I am assuming any fuzzy search would return the matches and rate them according to how similar they are to the search term. Perhaps I can choose some kind of cut-off value, where any matches that are less than 30% similar (I've no idea just guessing here) are assumed not equal whereas higher ranked matches are assumed a possible match. Perhaps this makes it easier (perhaps harder, I dunno), but I forgot to mention that the search term cannot contain any spaces. Player screen names can contain spaces though. I am thinking to just strip out the spaces of each name before starting the search, but perhaps there are better solutions in combination with fuzzy searching...
View 13 Replies
Feb 9, 2010
I have a binary file. If I look at it with a hex editor, the first values are:208, 207, 17, 224, 161, 177, 26, 225, 0, 0, 0, ... etc.It has a length of 330240 bytes I have tried to open it and read it into a string so I can manipulate it and write it back. No matter what I use, I either don't get the correct number of bytes or the values in the string are incorrect. The most common error results in the first values being: 63, 63, 17, 63, 63, 26, 0, 0, 0 .... etc.It is interesting that it appears that any value > 63 becomes 63.
I get the 2nd values by a simple loop:
For lnx = 0 To 99
Debug.Write(Asc(line.Substring(lnx, 1)))
Next
I have tried a whole number of ways to read in the file, including filestream, My.Computer.FileSystem.ReadAllText, File.io.readAllLines, etc.All either give me a string length of about 324000 (not sure why) or, if they do, don't have the correct values. Yes, I have tried various encoding options.
I need to find a string (sort of like: "D" & Chr(0) + "L" & Chr(0) + "S" & Chr(0)... ) so I can then replace that portion of the string with a new value, then write out the file.I use the ".indexOf" to find the data in the string.Why can't I load the file into a string? Or, do you know of an easy way to find some text (similar to above) in a file and then replace the next x number of bytes with a new value and close the file?
View 12 Replies
Aug 21, 2009
when i copy code from vb.net code window, and paste it in my richtextbox, the color synthax is as it displays in my vb.net code window.. this i want to keep when finding and replacing words. i have the following code to find and replace,
RichTextBox1.Text = RichTextBox1.Text.Replace("Private Sub", "<font color=blue>Private Sub</font>")
but the color syntax of the richtextbox code is lost, looks like a textbox's text.. how do i replace the words and keep the synthax coloring?
View 5 Replies
Mar 28, 2012
I've got an issue with a program I am writing. The specific issue is replacing characters in a parent string by finding, and matching, specific characters within it that are parsed from an external xml file. It's for a chat-like client.Here's the 2 classes I am using to pull the emote strings, titles, and id from external XML:
Imports System.Text.RegularExpressions
Imports System.Xml.Serialization
Public Class emote
[code].....
View 1 Replies
May 18, 2011
txt1 = help and txt2 = me! txt3 = not here, when i enter the other box i want the okay to drop sign to come up, after drop txt1=me! and txt2 = help.if i drag to txt3 display the can't drop sign.Iv'e tried everything all i can do is replace one way.also,i want the can't drop and can drop simbols to show.so far
Public
Class Form1
Private
Sub tbMouseDown(ByVal
[code]....
View 3 Replies
May 19, 2009
I have a code to read and find match the same value of a text file.This is the code.
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
[Code]...
View 8 Replies
Sep 17, 2009
I have two files like this
File one
[2 11.63 39.7] X7.705 Y0.735 209.037
Open -209.037
18N694 P321 117461, 50374 100MIL;
[code]...
what i need to do is from file 1 let say my line is like this
[2 11.63 39.7] X7.705 Y0.735 209.037
Open -209.037
18N694 P321 117461, 50374 100MIL;
from the line i must take P321 and match with my File2 if i find the mathing line like this
12N709 11.3611 4.9474 P321 L6 BOTTOM 100MIL 43-CHISEL X11.3611Y4.9474 1922 0
then i must take the value beside P321 which is L6 and write it in my original file like this
[2 11.63 39.7] X7.705 Y0.735 209.037
Open -209.037
18N694 P321 117461, 50374 100MIL; L6
How we can do this. To get the P321 from my file 1 can i use regex pattern like this P*[0-9]. And how to match the regex pattern with file 2 write the content ?
View 1 Replies
Oct 23, 2010
How to store fingerprint images in the vb.net and how to match it??"
View 1 Replies
Sep 12, 2011
At first i thought it was the padding since mcrypt uses zero padding but i changed the php to use PKCS7 and get the same exact results.I think it has something to do with the padding in the php.Test output from .Net:
Key: d88f92e4fa27f6d45b49446c7fc76976
Text: Testing123
Encrypted: /DMkj7BL9Eu2LMxKhdGT+A==[code]......
View 2 Replies
Apr 22, 2009
I have text like following example
XXZZXXXZXXZXXXXZZZZZZXVVVVVXZVZ
and also I have two patterns like XX and ZZ I want to find longest possible string which include above given two patterns and return starting and finishing index of the array.
View 3 Replies
Nov 29, 2011
In VB6 datacombobox there was a property that you could set that filtered the item list as you typed in the combo box (extended matching I think it was called) so that as the user typed more characters in the box the filtering progressively narrowed down the number of items in the list.The .net control does not seem to have this facility, or does it?Do we have to programatically do it now?
View 7 Replies
Aug 19, 2009
Have text file with two parts
[CODE]...
The upper part and the part after the line *+*+* Top *+*+*. What i must do is i must read the value in () at the Top part and compare that value with value in [] from upper part and write it side by side
This is my code so far:
Private Function GetLineMatch(ByRef LineToMatch As String, ByVal LineNumber As Integer, ByVal FileContents() As String) As String
Dim value As String = System.Text.RegularExpressions.Regex.Match(LineToMatch, "([d
[CODE]...
If u see the highlighted value are same. But from top part when it read (2 13.50 26.3)it only matches for one time the value in [2 13.50 26.3] so it take the first line and write and iqnore the second line.
View 3 Replies
Aug 19, 2009
I have text file with two parts
[code]...
If u see the highlighted value are same. But from top part when it read (2 13.50 26.3)it only matches for one time the value in [2 13.50 26.3] so it take the first line and write and iqnore the second line
View 1 Replies
Dec 21, 2009
In a table I have news posts with these fields:
Title
Content
OwnerID
The OwnerID relates to the ID in the users table, how can I get the name of the user who's ID matches the OwnerID? I'm writing a website in ASP.net (VB).
View 1 Replies
Jan 11, 2011
I am working on an application that llops through a dataset. Within each loop, I need to test to see if the datarow number is contained within an array. For example:For Each Page in Pages Test to see if page number is found in array (i.e. page number = 3, array = 1, 3, 4, 7, 8)Next Page The test would match on record numbers 1, 3, 4, 7, 8.
View 2 Replies
Nov 20, 2010
I have customer data in two different 3rd party apps that I need to organize into some reasonable data structure before making changes. I currently have two sub-classes of customer, one for each 3rd party app.[code]I need to map all instances of Customer1 to their respective Customer2s.I have an algorithm that has the logic to given an instance of Customer1 and a list of Customer2s find the appropriate match.Customers aren't the only data being matched between the two applications. I've also got two Item classes, two Payment classes, two Invoice classes, etc. Each of these classes has its own algorithm to match instances...I'd like to maximize the amount of reusable code. What is a good design pattern for matching portion?What data structure do I store a matched object pair in?
View 1 Replies
Apr 16, 2009
how would i get this USERNAME, USERID from this string:
Code:
<a href="javascript:attackWindow('USERNAME','USERID','50','RANDSTRING', 'RANDSTRING2')">
Adding the USERNAME to listbox, and then USERID into an array separated by a space.
View 2 Replies
Mar 30, 2011
How ever it is returning wrong results. Any one spot the mistake. Needs to return the username / ID from every online user from [code]...
View 3 Replies
Jan 21, 2011
I hoped you could give me som tips about speeding up som code i have to match an item to a collection of items... I have 1250 items that need to find the best match from 16774 items(every item is a class that consist of a string variable containing the path to an image, and 9 fields containg the most dominant color from a collection of 13 colors(the closest color)) The program does not use the filename or do any color matching in this step, only check the 9 fields... but it takes so
[Code]...
View 1 Replies
Jul 22, 2011
In javascript I know you can put for instance if date= "2010"* which would do the if for the string if it starts with 2010 but it doesn't matter what comes after that.
View 4 Replies
Sep 2, 2009
I have 2 file like this[code]...
But it not checking for non matching value and it writing everything from file 1 but i just want the line which is not matching with file 2 .
View 2 Replies
Sep 3, 2009
I have 2 file like this[code]...
But it not checking for non matching value and it writing everything from file 1 but i just want the line which is not matching with file 2 .
View 2 Replies
Feb 23, 2009
I'm playing a simple textbased game. And then I thought why not try to create a bot. But there's one problem. A CAPTCHA...But this captcha is very simple. It's 3 random numbers wich always uses the same font, size etc.For the simplicity we can say that it uses 9 different images and randomly puts together 3 of em.I then remembered a client for a java game that matched images with text on the screen to read the text.How can I make a program that does something like this:
if imageA.bmp exists on screen then
captcha &= a
End If
View 1 Replies
Feb 29, 2012
I have these following lines to send bytes using socket
Dim server As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim myIp As IPAddress = IPAddress.Parse("myIP")
Dim ip As New IPEndPoint(myIp, Int32.Parse("myPort"))
[Code]....
As in the code, I am supposed to retrieved "Halo". Instead I keep receiving sth like "[]".
View 1 Replies
Dec 12, 2010
I have a textbox for searching a database. When the text changes it runs a functioncFilter() and loads the records. It is set up to search different columns of a database, and it unfortunately only the first record matching is pulled from the database. Example: when the database contains two people (Bob Smith & Bob Smitt) the user can type the name in the search field. However When the user types Bob Smit it only returns Bob Smith and not both names in the database. I want this to act as a filter, dynamically changing the last with each additional letter typed in the search box. Below is my source code,
Public Sub cFilter()
Dim myConnectionstring As String = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Settings.dbLocation & ";Persist Security Info=True;Jet OLEDB:Database Password=BCFAdmin")
[code].....
View 4 Replies