Consulting

Results 1 to 2 of 2

Thread: Regular Expression for a text file

  1. #1

    Regular Expression for a text file

    Hello all,

    I am having a text file with the following data.


    d:\Sandbox\BMW35UP_Testview_I320\MainMicro\Application\Abs\Abs_Main\DOCS\Pu blic\TrimInfo\Canape\project.pj
    d:\Sandbox\BMW35UP_Testview_I320\MainMicro\Application\Abs\Abs_Main\SOURCE\ project.pj
    /SCS/SCS_Core_Based/08_Software/Application/ABS/ABS_GEN1/MAIN/APPLICATION/SOURCE/abs.h 1.9.1.1 d:\Sandbox\BMW35UP_Testview_I320\MainMicro\Application\Abs\Abs_Main\SOURCE\ abs.h
    /SCS/SCS_Core_Based/08_Software/Application/ABS/ABS_GEN1/MAIN/APPLICATION/SOURCE/abs_calibration_database_sub.h 1.3.2.1 d:\Sandbox\BMW35UP_Testview_I320\MainMicro\Application\Abs\Abs_Main\SOURCE\ abs_calibration_database_sub.h
    /SCS/SCS_Core_Based/08_Software/Application/ABS/ABS_GEN1/MAIN/APPLICATION/SOURCE/abs_conditional_switches.h 1.8.1.1 d:\Sandbox\BMW35UP_Testview_I320\MainMicro\Application\Abs\Abs_Main\SOURCE\ abs_conditional_switches.h


    i want to implement regular expression for all the lines in a file

    Regex pattern ="^ .*\n" and replace width =""


    kindly help me in this regard..

    Thanks & Regards,
    Sampath

  2. #2
    I copied this example from Microsoft's help pages for Regex.Replace:
    Imports System.Text.RegularExpressions
    
    Module Example
       Public Sub Main()
          Dim pattern As String =  "(\p{Sc}\s?)?(\d+\.?((?<=\.)\d+)?)(?(1)|\s?\p{Sc})?" 
          Dim input As String = "$17.43  €2 16.33  £0.98  0.43   £43   12€  17" 
          Dim replacement As String = "$2" 
          Dim rgx As New Regex(pattern)
          Dim result As String = rgx.Replace(input, replacement)
    
          Console.WriteLine("Original String:    '{0}'", input)
          Console.WriteLine("Replacement String: '{0}'", result)                             
       End Sub 
    End Module 
    ' The example displays the following output: 
    '       Original String:    '$17.43  €2 16.33  £0.98  0.43   £43   12€  17' 
    '       Replacement String: '17.43  2 16.33  0.98  0.43   43   12  17'
    Is that more or less what you are looking for?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •