How to manipulate string

Hi Guys,

This is my string: Transporter Doc. No & Date : 17392 & 22/10/2018
I have separated this string using split string like as TransporterDocNoDate.Split("&".ToCharArray)(1)

but in case date[ & 22/10/2018] missing, my workflow getting failed. how could handled this.

1 Like

this is outof index

Buddy may i know what value you want here buddy @smita.mobifly
from this
in_text = "Transporter Doc. No & Date : 17392 & 22/10/2018"

Fine if you are trying to get the date next to & symbol
then use this buddy
out_date = Split(in_text,"&")(1).ToString.Trim
this would fetch you the value of “22/10/2018”

And is there is no value next & or even there is no & you can handle it with a try catch block buddy
put the above two assign activities in try block and mention a log message activity in catch with a message like “there is no & and no more string next to &”
This implies that when there is value, you will get from try block with the date value or if not the workflow will go to catch block as it catches the exception and wont stop the workflows execution, thus showing log message like you dont have any & or value next to &…
Simple buddy
Kindly try this and let know buddy @smita.mobifly
Cheers

hi @Palaniyappan,

I want Both value Transporter Doc. No: 17392
Date: 22/10/2018
and i handled this but in case date missing then i want “null” value

Fine
That sounds clear,
so
to get the Transporter Doc. No:
like this buddy
in_text = "Transporter Doc. No & Date : 17392 & 22/10/2018"

Fine if you are trying to get the date next to & symbol
then use this buddy
out_TransporterDocno = Split(Split(in_text,":")(1).ToString.Trim," ")(0).ToString.Trim
Modified @smita.mobifly

then for date
like this buddy
out_date = Split(in_text,"&")(1).ToString.Trim
if there is date value you will get the date or
if you have place this in Try Block of Try Catch activity and if there is no value for data, then you can handle in catch with an assign activity like this
out_Date = “Null” (null as a string)
or
out_Date = String.Empty

Cheers buddy @smita.mobifly
Kindly try this and let know buddy

i tried this but wanted to pass into db only null not string

database accept null value not "null"

Then try with String.Empty buddy @smita.mobifly
Database would take that buddy

in my database empty value in place of date not accepted, wanted to pass null

hardcoded null but without quote.tell me how to pass

1 Like

Fine use Nothing buddy @smita.mobifly instead of Null
that means the same @smita.mobifly

@smita.mobifly

You can try regex.

 string_value1 = system.text.regularexpressions.regex.match(your_input,"(?<=:\s)(\d+)(?=\s&)").value

string_value2 = system.text.regularexpressions.regex.match(your_input,"(?<=&\s)(\d{1,2}\/\d{1,2}\/\d{2,4})").value

were you able to pass null value by mentioning as Nothing buddy @smita.mobifly

no , its blank …but its ok…we will into excel replace with “null” to null

1 Like

aah then fine i thought you are passing directly as insert statement with the value…if you are passing from a excel you can replace the value with for each row loop and a if condtion like
String.IsNullOrEmpty(row(“columnname”))
Then
row(“columnname”) = “Null”

But any how this will add as string only buddy… @smita.mobifly
I think nothing will work perfectly buddy, for more info look at this, even i verified

Cheers @smita.mobifly

any issues still buddy @smita.mobifly

hi @Palaniyappan
i have one issue:

  1. String ---- gstin:32AACCS0144E1Z2GLAXO SMITH KLINE ASIA PRIVATE LIMITED
  2. string ------gstin:URP SMITH KLINE ASIA PRIVATE LIMITED

wanted to extract 32AACCS0144E1Z2GLAXO or URP
i used like String.SubString(0,15),
this code useful for 1st string but failed for 2nd string.

try like this buddy
intext = “gstin:32AACCS0144E1Z2GLAXO SMITH KLINE ASIA PRIVATE LIMITED”

outtext = split(split(intext,":")(1).ToString," ")(0).ToString.Trim

this will give 32AACCS0144E1Z2GLAXO

and for it applies the same for the second one as well
Cheers @smita.mobifly

1 Like

sorry actually string is like
1st string: GSTIN : 32AAC CS014 4E1Z2
GLAXOSMITHKLINE CONSUMER HEALTH CARE LTD
KERALA

2nd string: GSTIN : URP
United Distributors (Nepal) P.Ltd
OTHER COUNTRIES
wanted to extract 32AACCS0144E1Z2 or URP

no worries buddy
intext = “GSTIN : 32AAC CS014 4E1Z2
GLAXOSMITHKLINE CONSUMER HEALTH CARE LTD
KERALA”

outtext = split(split(intext.split(Environment.Newline.ToArrray())(0),":")(1).ToString.Trim," ")(0).tostring.trim

1 Like