Whole word string replacement in LV7.1

Is there anyway to do whole word string replacement in 7.1?
For example, if I have the string "x21+sin(x2)" and I want to replace "x2" with "b2" without accidently changing "x21" into "b21". I saw that 7.1 does not support the word boundary "\b" in regex.

The easy solution is to search for "(x2)" and replace with "(b2)" but if you're not sure that x2 will always be in parenthesis, then another solution would be to get the next character after "x2" is found, and if it is not a number (0-9) then you have found x2, if it is a number then you have found x21, or x22, etc.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

Similar Messages

  • Replace Function: Replacing Whole Words Only

    I'm enhancing the verity search on a project I'm working on,
    removing the operator words (as well as others) from search
    criteria before passing it to the verity engine. The only problem
    I'm having so far is stripping out the whole words "AND", "OR", and
    "NOT" from user-specified search criteria. I obviously want to do
    it only in cases where "AND", "OR", and/or "NOT" are the whole
    word, and not replace things like "hand", "organization", and
    "notingham". It's probably so simple, but I'm a bit stumped.
    While I'm here, has anyone developed anything to enhance
    verity results, or know of a resource I could look into
    further?

    you can do this with ReReplace()
    look in the documentation for "boundary", somewhere in the
    regex
    documentation, and you'll find what you're looking for. i
    think it's "\b",
    so it's something along the lines of
    ReReplace(str,"\b(and|or|not)\b","","all")
    "ckbentdesigns" <[email protected]> wrote in
    message
    news:etsdqh$igj$[email protected]..
    > I'm enhancing the verity search on a project I'm working
    on, removing the
    > operator words (as well as others) from search criteria
    before passing it
    > to
    > the verity engine. The only problem I'm having so far is
    stripping out the
    > whole words "AND", "OR", and "NOT" from user-specified
    search criteria. I
    > obviously want to do it only in cases where "AND", "OR",
    and/or "NOT" are
    > the
    > whole word, and not replace things like "hand",
    "organization", and
    > "notingham". It's probably so simple, but I'm a bit
    stumped.
    >
    > While I'm here, has anyone developed anything to enhance
    verity results,
    > or
    > know of a resource I could look into further?
    >

  • Find whole word

    How i can find whole words only in a string?
    If we have a string like "Hello any person in any part of world" And User searches for "an"
    in normal search, he finds 2 match But he must find it only if the string has contained "an" as a whole word  like "this is an apple"
    It may be possible.

    Hi
    As usual, late to the party.  Here is an example in the form of a stand alone Project.
    ' new Project with default BLANK Form1
    ' replace ALL Form1 code with this code.
    ' Illustrates simple word find in string
    ' using simple RegEx with CASE/NO CASE.
    Option Strict On
    Option Explicit On
    Option Infer Off
    Imports System.Text.RegularExpressions
    Public Class Form1
    Dim rtb As New RichTextBox
    Dim tb1, tb2, tb3 As New TextBox
    Dim lab1, lab2 As New Label
    Dim b, b1 As New Button
    Dim cb As New CheckBox
    Dim r1, r2, r3 As New RadioButton
    Dim NormalF As New Font(rtb.Font.FontFamily, 12, FontStyle.Regular)
    Dim HiLight As New Font(rtb.Font.FontFamily, 16, FontStyle.Bold)
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Me.Size = New Size(300, 550)
    With rtb
    .Location = New Point(5, 5)
    .Text = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" & vbCrLf
    .Text &= "{.An.} This .AN.is a {an}test string using completely random words and characters and is NOT a sentence. An they show any of another [An] yet another set of an characters (an) numbers an dots ... and a lot of spurious characters An an AN aN type entries....." & vbCrLf & "30/12/2013 12.30.2013 2013\12\30"
    .Multiline = True
    .Size = New Size(270, 200)
    .BackColor = Color.Khaki
    .ForeColor = Color.Maroon
    .Font = NormalF
    .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
    .BorderStyle = BorderStyle.FixedSingle
    .ScrollBars = CType(ScrollBars.Vertical, RichTextBoxScrollBars)
    End With
    With lab1
    .Text = "Pattern"
    .Location = New Point(5, 430)
    .AutoSize = True
    .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Bottom
    End With
    With tb1
    ' date finder
    .Text = "(?<month>\d{1,2})[/\\.-](?<day>\d{1,2})[/\\.-](?<year>\d{2,4})\b|\b(?<year>\d{2,4})[/\\.-](?<day>\d{1,2})[/\\.-](?<month>\d{1,2})"
    .Location = New Point(56, 425)
    .Width = 100
    .BackColor = Color.Khaki
    .ForeColor = Color.Maroon
    .Font = New Font(Me.Font.FontFamily, 12)
    .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Bottom
    .BorderStyle = BorderStyle.FixedSingle
    End With
    With tb2
    .Location = New Point(5, 215)
    .Multiline = True
    .Size = New Size(270, 200)
    .BackColor = Color.Khaki
    .ForeColor = Color.Maroon
    .Font = New Font(Me.Font.FontFamily, 12)
    .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top Or AnchorStyles.Bottom
    .BorderStyle = BorderStyle.FixedSingle
    .ScrollBars = ScrollBars.Vertical
    End With
    With lab2
    .Text = "Search"
    .Location = New Point(5, 460)
    .AutoSize = True
    .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Bottom
    End With
    With tb3
    .Text = "an"
    .Location = New Point(56, 455)
    .Width = 100
    .BackColor = Color.Khaki
    .ForeColor = Color.Maroon
    .Font = New Font(Me.Font.FontFamily, 12)
    .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Bottom
    .BorderStyle = BorderStyle.FixedSingle
    End With
    With b
    .Text = "Find"
    .Location = New Point(210, 486)
    .Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
    .Width = 50
    End With
    With b1
    .Text = "Clear"
    .Location = New Point(160, 486)
    .Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
    .Width = 50
    End With
    With cb
    .Text = "Ignore CASE"
    .Checked = True
    .Location = New Point(0, 486)
    .Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
    .RightToLeft = Windows.Forms.RightToLeft.Yes
    End With
    With r1
    .Width = 16
    .Text = Nothing
    .Checked = False
    .Location = New Point(tb1.Right + 15, tb1.Top)
    .Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
    End With
    With r2
    .Width = 16
    .Text = Nothing
    .Checked = False
    .Location = New Point(tb3.Right + 15, tb3.Top)
    .Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
    End With
    With r3
    .Text = "ALL"
    .Checked = True
    .Location = New Point(tb3.Right + 45, tb3.Top)
    .Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
    End With
    Me.Controls.AddRange({rtb, lab1, lab2, tb1, tb2, tb3, b, b1, cb, r1, r2, r3})
    AddHandler b.Click, AddressOf b_Click
    AddHandler b1.Click, AddressOf b1_Click
    AddHandler r3.CheckedChanged, AddressOf ALLselected
    AddHandler cb.CheckedChanged, AddressOf KeepCase
    Me.Width = 500
    tb3.Select()
    End Sub
    Private Sub DoFind()
    ' set the pattern to use depending on Radio button selected
    Dim pattern As String = Nothing
    Select Case r3.Checked
    Case True
    ' use straight text pattern
    pattern = tb3.Text
    Case Else
    Select Case r1.Checked
    Case True
    ' use pattern as entered by user
    pattern = tb1.Text
    Case Else
    ' use basic regex pattern
    pattern = "\b" & tb3.Text & "\b"
    End Select
    End Select
    ' ignore case
    Dim rgxCI As New Regex(pattern, RegexOptions.IgnoreCase)
    ' case sensitive
    Dim rgxCS As New Regex(pattern, RegexOptions.None)
    rtb.SelectAll()
    rtb.SelectionBackColor = rtb.BackColor
    rtb.SelectionFont = NormalF
    If tb3.Text.Length < 1 Then Exit Sub
    Select Case cb.Checked
    Case True
    tb2.AppendText(vbCrLf & "CASE INSENSITIVE pattern = " & pattern & vbCrLf)
    Dim m As MatchCollection = rgxCI.Matches(rtb.Text)
    If m.Count < 1 Then
    tb2.AppendText("No Matches for '" & pattern & "'" & vbCrLf)
    Else
    tb2.AppendText("Found " & m.Count.ToString & " Matches, indexes = ")
    End If
    For Each match As Match In m
    rtb.SelectionStart = match.Index
    rtb.SelectionLength = match.Length
    rtb.SelectionFont = HiLight
    rtb.Refresh()
    rtb.SelectionBackColor = Color.LightBlue
    tb2.AppendText(match.Index.ToString & " ")
    Next
    Case Else
    tb2.AppendText(vbCrLf & "CASE SENSITIVE pattern = " & pattern & vbCrLf)
    Dim m As MatchCollection = rgxCS.Matches(rtb.Text)
    If m.Count < 1 Then
    tb2.AppendText("No Matches for '" & pattern & "'" & vbCrLf)
    Else
    tb2.AppendText("Found " & m.Count.ToString & " Matches, indexes = ")
    End If
    For Each match As Match In m
    rtb.SelectionStart = match.Index
    rtb.SelectionLength = match.Length
    rtb.SelectionFont = HiLight
    rtb.Refresh()
    rtb.SelectionBackColor = Color.Pink
    tb2.AppendText(match.Index.ToString & " ")
    Next
    End Select
    tb2.AppendText(vbCrLf)
    End Sub
    Private Sub b_Click(sender As Object, e As EventArgs)
    DoFind()
    End Sub
    Private Sub b1_Click(sender As Object, e As EventArgs)
    tb2.Text = Nothing
    tb3.Text = Nothing
    rtb.SelectAll()
    rtb.SelectionBackColor = rtb.BackColor
    rtb.SelectionFont = NormalF
    End Sub
    Private Sub ALLselected(sender As Object, e As EventArgs)
    Dim rb As RadioButton = DirectCast(sender, RadioButton)
    If rb.Checked Then
    cb.Visible = False
    cb.Checked = True
    Else
    cb.Visible = True
    End If
    End Sub
    Private Sub KeepCase(sender As Object, e As EventArgs)
    Dim cb As CheckBox = DirectCast(sender, CheckBox)
    If r3.Checked Then
    cb.Visible = False
    cb.Checked = True
    Else
    cb.Visible = True
    End If
    End Sub
    End Class
    Regards Les, Livingston, Scotland

  • Searching for a whole word within a sentence

    I am trying to search for a whole word only in a sentence. The problem is if I use CS then I get things that contain the string in other words. If I use CO or CP then there is no match because there are other words in the sentence. I don't think it's practical to split the sentence into individual words and then compare each word as the sentence is of an unknown length and could be made up of many words.
    An example:
    Sentence 1 - THIS IS ABOUT RF OUTPUTS.
    Sentence 2 - THIS IS ABOUT MY PERFORMANCE
    The user wants to search for sentences containing RF. In this search I only want sentence 1 to be found and not the RF in the word performance in sentence 2.
    Can anyone tell me how to do this.
    Many thanks
    Karen

    DATA: str1(50),
          str2(50),
          srchstr(10).
    DATA: BEGIN OF st_str,
            str(50),
          END OF st_str.
    DATA: it_tab LIKE TABLE OF st_str WITH HEADER LINE.
    str1 = 'THIS IS ABOUT RF OUTPUTS RF'.
    str2 = 'THIS IS ABOUT MY PERFORMANCE RF'.
    srchstr = 'RF'.
    SPLIT str1 AT space INTO TABLE it_tab.
    LOOP AT it_tab WHERE str = srchstr.
      WRITE : srchstr.
      WRITE 'found in'.
      WRITE 'str1'.
      EXIT.
    ENDLOOP.
    CLEAR it_tab[].
    SPLIT str2 AT space INTO TABLE it_tab.
    LOOP AT it_tab WHERE str = srchstr.
      WRITE : srchstr.
      WRITE 'found in'.
      WRITE 'str2'.
      EXIT.
    ENDLOOP.
    Check this code as it solves the leading RF and trailing RF problem .

  • String replacement

    Hi, anyone knows how to replace a particular string in a file with another string?
    For example, in the file hello.tmp,
    I want to replace the word :Smile: with the string
    <img src="smile.gif">
    I tried to use String.replace() but this is only for characters.
    Anyone knows how to replace Strings??
    Hope to hear from anyone really soon. Very urgent!!!

    There is no direct method to replace a string in file. The code goes like this:
    import java.io.*;
    import java.util.*;
    public class StringReplacer
         private String replaceString;
         private String replacerString;
         private String filePath;
         public StringReplacer(String replaceString, String replacerString, String filePath)
              this.replaceString = replaceString;
              this.replacerString = replacerString;
              this.filePath = filePath;
              try
                   replace();               
              catch (Exception ex)
         private void replace() throws Exception
              File file = new File(filePath);
              if(!file.exists())
                   System.out.println("File doesnot exists");
                   return;
              DataInputStream dis = new DataInputStream(new FileInputStream(file));
              StringBuffer fileData = new StringBuffer("");
              String strTemp = "";
              while((strTemp = dis.readLine()) != null)
                   fileData.append(strTemp);
              dis.close();
              StringTokenizer stTemp = new StringTokenizer(fileData.toString(), replaceString);
              int tokens = stTemp.countTokens();
              if(tokens <= 1)
                   //No matches found for string to be replaces.
                   System.out.println("No matches found for string to be replaced");
                   return;
              fileData = new StringBuffer("");
              while(stTemp.hasMoreTokens())
                   fileData.append(stTemp.nextToken() + replacerString);     
              if(file.exists())
                   file.delete();
              file = new File(filePath);
              if(!file.exists())
                   file.createNewFile();
              DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
              dos.writeChars(fileData.toString());
              dos.flush();
              dos.close();
         public static void main(String [] args)
              //create an object of StringReplacer here.
    }

  • Whole-word search in project

    I'm running RH for HTML Help X4.1 on Windows XP. I want to
    search through all the text in all of the topics for a particular
    word or word string. Is that possible? I can't find anything that
    lets me do that? I realize this is NOT Win Help where I'd be
    searching a Word document, but it would be very helpful to be able
    to do a whole-word search of the project. Thanks.
    -david

    Just a word of warning. It is good practice to close your RH
    project down as the in built tool does occasionally fail to spot
    instances in open topics/projects. Personally most authors on here
    prefer to use other tools (e.g.
    FAR or
    BkReplacem).

  • Regarding String Replacing ....

    Hi Friends,
    I have some problem regarding String replacing.
    ex.
    I have following string ::
    =================================================
    This is the java manager the main purpose for the jasper is used to create reports.
    And the Java language is very extensible.
    Is this the proper string functions provided by java isn't it ?
    *================================================*
    *i want to replace word "is"  with "IS". but that word is not connected to word like  Th{color:#ff00ff}is{color}*
    *differ from simple separate "{color:#ff0000}is{color}" so Word should not be replaced in This only separate "is"*
    *must be replaced. ?*
    *Any Idea ?*
    *{color}*
    Edited by: Ghanshyam on Sep 14, 2007 4:27 PM

    How about just searching for and replacing
    " is "
    instead of
    "is"
    So, using this code from the Java Developers Almanac 1.4 (2002 Addison-Wesley):-
    static String replace(String str, String pattern, String replace) {>    int s = 0;>    int e = 0;>    StringBuffer result = new StringBuffer();> >    while ((e = str.indexOf(pattern, s)) >= 0) {>       result.append(str.substring(s, e));>       result.append(replace);>       s = e+pattern.length();>  result.append(str.substring(s));
    return result.toString();
    }Your would use:-
    String newStr = replace(originalStr, " is "," IS ");
    Edited by: mad_scientist on Sep 14, 2007 4:16 AM (Sorry about all the edits, just getting used to the formatting on here)
    Edited by: mad_scientist on Sep 14, 2007 4:22 AM
    Edited by: mad_scientist on Sep 14, 2007 4:24 AM

  • PLD String Replace Function?

    Hello Experts,
    I would like to use the Sum in Words option in the field properties Format tab. However, I would like to have this in a language for which there is no LRF.
    I have read all the various Sum in Words/Amount in Words threads I can find but I have no special locale based requirements (lacs etc). The default answer seems to be to prepare a FMS query and attach it to a UDF, then pull the variable into PLD.
    Rather than rewriting the functionality, it would be far easier for me to use a series of Replace functions (the structure of Turkish for amount in words is exactly the same as English and translating each word (One, Two... Ten, Twenty... etc) with a Replace would solve my problem.
    Looking at the documentation for PLD, I can see no prebuilt Replace function - is there any way this can be achieved?
    If not, is there any Sum in Words function in B1 queries so I can at least do the replace there rather than writing an entire convert to words query?
    Thank you.

    Wasn't able to force a string replace - had to hex edit the LRF instead. Quick and dirty, but it works.

  • Why does double-click no longer select a whole word?

    I am on the beta update channel and currently using FF 8.0, latest update as of the moment of this posting.
    I am not sure when it happened - I think since I started using 8.0 - but double-click no longer selects a whole word. It's the same effect as a single click - simply positions the insertion point where the mouse cursor is located.
    This is very aggravating. I thought it may be a bug in the new version (I already posted it to Bugzilla, but hasn't been confirmed yet), Unfortunately, I don't have the old version to cross-check (can I install both versions on one machine?)
    Or is it some configuration issue? Or conflict with something else? I've searched and not (yet) found any other complaints about this issue from other users.
    Note that I do not have the problem in any other app nor in other browsers that I have installed (e.g., IE, Chrome, Opera, Safari). In all of those, double-click on a word selects the whole word.
    Thanks in advance for any suggestions or guidance.
    Best,
    Yosh

    OK - I found the culprit. It seems that the Answers.com '''1-Click Answers''' utility had changed its behavior. In its Options on the Activation tab is an option to activate it when using double-click in a browser. I don't remember turning it on, but it ''was'' on. When I turned that option off, the problem went away. Apparently it is not compatible with FF8, since double-click was apparently intercepted, but 1-Click Answers was not activated - the double-click simply became a no-op.
    Now that I've turned off that option, double-click in FF8 is back to the way it's supposed to work for quickly selecting a whole word or sentence.
    If anyone else encounters this problem, I hope this information will help to resolve it.

  • How to copy and paste the whole word or excel form in the infopath form control

    Is there any control in infopath 2010. when the form will be open and users wants then can copy whole word or excel form on this control.
    and in word form there is also a control.

    Hi John,
    You can do as the followings:
    Create a blank form with InfoPath Designer 2010,
    Add a Rich Text Box control and Submit button in the blank form
    Publish the form to your SharePoint site
    Open the form library and create a document
    Copy the table with text from word file
    Paste the table in the Rich Text Box area, the paste option is Keep Source Formatting
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • What is the unicode for ''  (need it to do String.replace)

    i'm trying to use String.replace(char a, char b)
    it won't compile if i do x.replace('_', '')
    help!
    thanks!

    Are you trying to remove all occurences of the underscore character from the string? If so create a StringBuffer from the string, loop through it and remove the characters as you find them.
    If you're using JDK1.4 you should eb able to use the new String method:
    public String replaceAll(String regex,
    String replacement)

  • String replace

    String has a replace method for chars, something the likes of
    String replace(char a, char b)
    I tend to think it would be nice to ammend String further with
    String replace(String a, String b)
    proponents/opponents? It seems like a nice thing to have.

    This type of method is available in the regex package
    (available in JDK 1.4). I am not expert or regular
    expressions but it will allow you to do this and much
    much more.I guess it will. Still it would be nice to have the ability directly inside String without explicitly having to instantiate a Pattern. I know there is a split method in String in JSDK 1.4 which takes a String specification of a regexp and internally compiles it. I guess my point is convenience but I should know the new APIs fully before writing more.

  • In SQL Worksheet, when I double click to select whole word with underscore

    Hi All
    I'm using SQL Developer 2.1 in XP. After I changed various preferences, I fid when I double click a variable such as ls_test_column, it considered it as 3 words instead of one. I know in TOAD there's a setup to consider word with underscore as one word so that when double click, the whole word can be selected. Now I have to use mouse or shift key to select variables with underscore. it's inconvenient.
    Does anyone know which preference control this? Thanks.

    It is based on the "Use Change of Case as Word Boundry" preference in the Code Editor section - if this is on, then an _ is considered a "change of case" for double click selection, amongst other things.
    theFurryOne

  • I want to modify the "find" box to be avble to only search for whole words.

    I want to modify the "find" box to look only for matching "whole words," otherwise--it's pretty pointless!!!

    Also, it is early in the day for this forum as far as activity by the contributor's who really know CSS coding. I bet someone else will have the codes you need later today.

  • Find/Change whole words in CS3

    Maybe I'm just being dense, but when I do a find/change in ID CS3 I can't find the option to search for whole words only. The default is set to ignore whole words, so I end up finding a lot of undesirable matches. My last search was for "air," so you can imagine how many false matches I got.
    This was quite obvious in CS2, but those options (including match case) seem to have moved somewhere where I can't find them.
    Any assistance would be most appreciated.
    Mark

    With your mouse, examine each of the icons under the Change field. A tooltip identifies each one. One of them is the one you want.
    Dave

Maybe you are looking for

  • Crystal report / adobe error

    hi there, i developed a web application using asp.net4.0, VS 2010 and crystal report for VS2010. everything working fine in development machine as well as local server machine. but the same failed in production and it gave the error message as "the f

  • (Problem with arrows )Adobe Reader doesn't work correctly

    I've problem with Adobe Reader plug-in. When I have open tab with pdf file, my arrow keys don't work in other tabs in firefox, only in this tab where it's open pdf file. Also I noticed that when trying to use the arrows in the other cards, they work

  • How to identify if a data node exist?

    Hi, If a form is binded to a schema, and when the xml is supplied to the form how to identify an optional node in the xml is available or not. for example if I have a XML input like below <root>      <childTable>                    <childRow>        

  • Help on 'GET_WEEK_INFO_BASED_ON_DATE'

    Hi all, I have problem with the following code. CALL FUNCTION 'WEEK_GET_FIRST_DAY'            EXPORTING                 week         = s_kweek            IMPORTING                 date         = s_date            EXCEPTIONS                 week_inval

  • Apple applications slow or not working

    When I booted up safari today my homepage wouldn't load at all. I thought it was the wifi so I tried another website which took quite some time, but eventually loaded. Every page has been the same, but once it's up it works fine. Anything I've typed