Hello All,
I have one query regarding regular expression implementation to a file.I have a large text file in which i am providing a set of lines has example:
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_lat_accel_signals\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/SOURCE/yib_swa_signals.h 1.10.1.4 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_lat_accel_signals\yib_swa_signals.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/SOURCE/yib_swa_signals_sub.h 1.11.1.4 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_lat_accel_signals\yib_swa_signals_sub.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/SOURCE/yib_swa_signals_trim.h 1.4.1.5 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_lat_accel_signals\yib_swa_signals_trim.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_fault_manager\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_fwd_rev_detection\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/SOURCE/yib_swa_signals_priv.h 1.9 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_lat_accel_signals\yib_swa_signals_priv.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_initialization\yib_polyspace_drs.h
if i give filename has yib_polyspace_drs.h then i should get below lines has output from regular expression
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_fault_manager\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_fwd_rev_detection\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_initialization\yib_polyspace_drs.h
/SCS/SCS_Core_Based/08_Software/Application/YIB/YIB_GEN2/MAIN/APPLICATION/DOCS/Private/TestSpecifications/yib_polyspace_drs.h 1.3 d:\Sandbox\BMW35UP_I390_1.443_Testview\MainMicro\Application\Yib\Yib_Main\_yib_lat_accel_signals\yib_polyspace_drs.h
Kindly help me to implement regular expression .
Thanks & Regards,
Sampath
Loading
VulpesPosted Nov 2, 2014, 1:48 PM
reg.Pattern = "^.*?\byib_polyspace_drs\.h\b.*$"
Note though that if a line contains two or more instances of yib_polyspace_drs.h 1.3 then the line will be matched if at least one of them is a complete word.
sampath mekaPosted Nov 2, 2014, 12:02 PM
sampath mekaPosted Nov 1, 2014, 9:08 PM
VulpesPosted Nov 1, 2014, 3:06 PM
In VBS you have to set a property of the RegExp object rather than insert (?m) in the regular expression itself.
The following script seems to be working OK:
VulpesPosted Nov 1, 2014, 1:45 PM
I'll get back to you later today.
sampath mekaPosted Nov 1, 2014, 1:28 PM
VulpesPosted Nov 1, 2014, 12:40 PM
It seems to be working fine:
sampath mekaPosted Nov 1, 2014, 10:58 AM
VulpesPosted Oct 31, 2014, 12:32 PM
http://www.c-sharpcorner.com/Forums/Thread/273948/how-to-implement-regular-expression-to-a-text-file.aspx
also works for the above file if it is indeed different from the previous one.
Note that if you want the text beginning d:\SandBox to begin on a different line, then the file will need to contain new line characters before that part of the text. At the moment it doesn't - it's all one line - when I paste it into notepad.
However, I see that you've now posted this question in the VB.NET category rather than in the C# category. So are you asking for the same code translated to VB.NET?