Using regex add hyphen first after two character then after four character

I am new in UIpath how can i add hyphen in string, first after two character then after four character.

Like i have string = “12F8JLK83”

using regex replace “12-F8JL-K83”;

Hi @pankajs3

Use the below expression using substring method

where str=“12F8JLK83”

str.Substring(0,2)+"-"+str.Substring(2,4)+"-"+str.Substring(str.Length-3)

1 Like

Thanks for your reply.

But i want any regex find the second position and then sixth position of given string

Just want to understand what difference it will make you use regex or substring, is there any specific reason you want to do this with regex

Use the below expression

Where str=“12F8JLK83”

Regex.Replace(str,"(.{2})(.{4})","$1-$2-")

Where (.{2}) - First capturing group and dot representing anything and exactly 2 times

Where (.{4}) - Second capturing group and dot representing anything and exactly 4 times

$1- : Represent the first capturing group and add hyphen after that

$2- : Represent the second capturing group and add hyphen after that

3 Likes

Thanks a lot. it’s good for me.

Q. Can you help me one more thing is that how can i get PDF full page image in jpg(multiple page how can i convert each page to in jpg).

Hi @pankajs3

Can you close the topic, if you have got your solution

Can you help me how can i convert PDF each page to JPG.

Hi @pankajs3

Refer the below post

1 Like

Thanks @anil5
But I want to convert pdf to image without using third party tool or any other online site. By Only using coding base.

Hi @pankajs3,

Using uipath tool you cannot do that, you have to use ghost script or abby

1 Like

Thanks @anil5
Using UIpath tool i can-not do but by using vb.net coding it is possible in “invoke code” activity. But i don’t know vb.net coding. that’s the problem.

Search in forum if others had the same issue, if you can get the solution, if not search in stack overflow, if the above can be done using vb.net code the code will be sure there in stack overflow.

using (FileStream file = File.OpenRead(@"..\path\to\pdf\file.pdf")) // in file { var bytes = new byte[file.Length]; file.Read(bytes, 0, bytes.Length); using (var pdf = new LibPdf(bytes)) { byte[] pngBytes = pdf.GetImage(0,ImageType.PNG); // image type using (var outFile = File.Create(@"..\path\to\pdf\file.png")) // out file { outFile.Write(pngBytes, 0, pngBytes.Length); } } }

and this links also [https://www.pqscan.com/convert-pdf/to-jpg-vb.html]

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.