Jump to content

Recommended Posts

Posted

tezhihi,
Sorry. It was for a better readability indeed  :>
If you keep this pattern then of course all whitespaces can be removed - and the (?x) too
I personally rarely use significant whitespaces in patterns, I better use \h etc which fit in most cases

  • 3 weeks later...
  • 3 weeks later...
Posted (edited)

Hi  @mikell Are I correct when use this script below for capture string 'D2596B055075' of path below.

$a = 'H:\01. PRODUCTION\01. NEW SHIPMENT\04-CASE RELATED AND NEWS AND BUSINESS\07-19-2017\Part C 16.00\D2596B055075\aaaaaaaaaa\66666666666666\6666666666666666666666'
; or
$a = 'H:\01. PRODUCTION\01. NEW SHIPMENT\04-CASE RELATED AND NEWS AND BUSINESS\07-19-2017\Part C 16.00\D2596B055075
$b = StringRegExpReplace($a, '(.*)\\(D.*?)(|\\(.*))', '$2')
ConsoleWrite($b)

 

Edited by tezhihi
Posted
9 minutes ago, tezhihi said:

Hi  @mikell Are I correct when use this script below for capture string 'D2596B055075' of path below.

$a = 'H:\01. PRODUCTION\01. NEW SHIPMENT\04-CASE RELATED AND NEWS AND BUSINESS\07-19-2017\Part C 16.00\D2596B055075\aaaaaaaaaa\66666666666666\6666666666666666666666'
; or
$a = 'H:\01. PRODUCTION\01. NEW SHIPMENT\04-CASE RELATED AND NEWS AND BUSINESS\07-19-2017\Part C 16.00\D2596B055075
$b = StringRegExpReplace($a, '(.*)\\(D.*?)(|\\(.*))', '$2')
ConsoleWrite($b)

 

use: 
 

_PathSplit()

 

Regards,
 

Posted (edited)
4 minutes ago, Trong said:

use: 
 

_PathSplit()

 

Just for dir ??????? u should run this script and understand what i mean.

Edited by tezhihi
Posted

nop
 

#include <Array.au3>
#include <File.au3>

Local $sFilePath='H:\01. PRODUCTION\01. NEW SHIPMENT\04-CASE RELATED AND NEWS AND BUSINESS\07-19-2017\Part C 16.00\D2596B055075'

Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = ""
Local $aPathSplit = _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension)
_ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath)

 

Regards,
 

Posted
3 hours ago, Trong said:

nop
 

#include <Array.au3>
#include <File.au3>

Local $sFilePath='H:\01. PRODUCTION\01. NEW SHIPMENT\04-CASE RELATED AND NEWS AND BUSINESS\07-19-2017\Part C 16.00\D2596B055075'

Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = ""
Local $aPathSplit = _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension)
_ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath)

 

I mean about catch only D2596B055075 not full file path @@. Find in string and replace and result is D2596B055075

Posted
1 minute ago, tezhihi said:

I mean about catch only D2596B055075 not full file path @@. Find in string and replace and result is D2596B055075

Whatever!
 

Local $string = "Whatever! Something, somethinglt is D2596B055075 Whatever! Something, something"
Local $searchstring = "D2596B055075"
Local $replacestring = "Whatever!!!!!!!!!!!!!"


Local $newString = StringReplace($string, $searchstring, $replacestring)

ConsoleWrite($string & @CRLF)
ConsoleWrite($newString & @CRLF)

 

Regards,
 

Posted (edited)

@tezhihi

The regex doesn't work because of the alternation in (|\\(.*))  : "match nothing or \\(.*)" . For the first string,  (D.*?) returns everything after D
If you remove the alternation it will work for the first but not for the second. And if you make the second part of the expression optional then it doesn't work for the first string again 

So assuming that the part you want always begins with a D, a correct way could be this

$b = StringRegExpReplace($a, '.*\\(D[^\\]+).*', '$1')

this expression matches "D and one or more non-backslash chars" (heeding the backslash just before the D)
:)
 

Edit
Trong, sometimes you have to guess a little what is the real question and so what should be a correct answer :D
i.e. the non-regex way

Local $b, $split = StringSplit($a, "\")
For $i = 2 to $split[0]
  If StringLeft($split[$i], 1) == "D" Then $b = $split[$i]
Next
msgbox(0,"", $b)

 

Edited by mikell
Posted
27 minutes ago, mikell said:

Trong, sometimes you have to guess a little what is the real question and so what should be a correct answer :D
i.e. the non-regex way

Local $b, $split = StringSplit($a, "\")
For $i = 2 to $split[0]
  If StringLeft($split[$i], 1) == "D" Then $b = $split[$i]
Next
msgbox(0,"", $b)

 

Sorry I have a problem communicating!
And limited English proficiency, my friend is Google Translate.

Regards,
 

Posted
3 minutes ago, Trong said:

Sorry I have a problem communicating!
And limited English proficiency, my friend is Google Translate.

@Trong chung quy là ông ko hiểu tôi nói cái gì đúng không :))

@mikell thanks you so much.

Posted
Just now, tezhihi said:

@Trong chung quy là ông ko hiểu tôi nói cái gì đúng không :))

đù Người Việt
Tiếng Việt =>  English => Tiếng Việt thì khó hiểu bỏ mịa =]]

Regards,
 

Posted (edited)
1 minute ago, Trong said:

đù Người Việt
Tiếng Việt =>  English => Tiếng Việt thì khó hiểu bỏ mịa =]]

Tôi thấy ông vào comment buồn cười quá nên cố tình thôi. Tôi đang hỏi về regex mà :)) đơn giản là tách cái D2506 xxx kia ra thôi chứ cái pathsplit hay string bla bla ko ra đâu tại đường dẫn nó thay đổi linh tinh. Ok cảm ơn nhé 

Edited by tezhihi
Posted

Những cái đó thì bạn phải nói rõ. Có cái gì,  cần cái gì và muốn kết quả thế nào thì người ta mới dễ giúp chứ!

Mà forum Việt nó không chào đón bạn à?  Chỗ đó nó cấm tôi, cấm mọi nơi lên nơi đây là nhà của tôi!

Regards,
 

  • Developers
Posted (edited)

Ok guys... back to English please in open forum.  Just keep practicing it and you will soon master it. :)

Jos

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
1 hour ago, Jos said:

Ok guys... back to English please in open forum.  Just keep practicing it and you will soon master it. :)

Jos

 

This is noted. Thanks you

  • 3 months later...
Posted (edited)

Hi @mikell,

 

Long time no make a question :(. I need to get some data from manifest.xml as blue highlight of image show below.

Highlight.png

So please check and provide me the correctness of my regex below:

Local $aLNI = StringRegExp($LNI, '.*guid="(.*?)"\soverrideConversionId.*', 1)
Local $aSource = StringRegExp($LNI, '.*source" name="(.*?)" md5sum.*', 1)
Local $Court = StringRegExp($LNI, '.*CLINV_code" value="(.*?)".*', 1)
Local $CharCount = StringRegExp($LNI, '.*estKeyCharCount" value="(.*?)".*', 1)

and if you can please provide me the way to use these regex in C#. Thanks you so much :D

 

Edited by tezhihi

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...