Hello dear fellow users. Im having a big problem (For me) and i need fast replies. So, im scraping data from this site and i want my data in format 1234567-8. So i wanna get rid of every line of text!
Here is the result i get: https://aijaa.com/AvVHuu
If you have a string that you scraped…
To remove alphas and specials from a string, there are a few ways:
String.Concat(text.Where(AddressOf Char.IsDigit))
or
System.Text.RegularExpressions.Regex.Replace(text, "[^0-9]", "")
to keep . and -
System.Text.RegularExpressions.Regex.Replace(text, "[^0-9.-]", "")
If you would like to pull out your number in a different way like using a pattern for example, we would need example text you are scraping.
(fyi, your image is broken and won’t load for me)
I have generated datatable, which scrapes the data shown in picture https://aijaa.com/AvVHuu
The goal is to only return the values which are in format 1234567-8 and cut out all the text and return the specified format to excel file and then the goal is to search with these results on a another website using for each row. The search in another site work with name of the company, but we need to change this name search to 1234567-8 for specific reasons
How can i use this: System.Text.RegularExpressions.Regex.Replace(text, “[^0-9.-]”, “”) in my workflow?
I put a random string in there, which can be a variable (like from the web or data table).
The Regex Replace will remove everything except the numbers and dash. Depending on what you want to extract though, you may need an adjustment to the pattern.
I tested the above example in the message box and it displayed only “1234567-8”
(also, the image still won’t load for me; it might be because I’m on a company proxy that blocks it)
Dear Clayton, we are very close now, thank you for that!
We are importing our result (1234567-8) to Excel sheet before doing another search on another site. Is it possible? Here is the result what we get now. I think i was asking wrong questions…
What you will want to do is Assign the value to the item in each row. So, if you are using a ForEach row activity, then in an Assign activity it would look like this:
Assign row.Item(“Yritys”) = “1234567-8”
(or row.Item(0) if you don’t want to use column name)
The next thing I will mention is that you will want a different Regex pattern I think. You will want one that only looks for numbers from 4-8 digits followed by a - and a digit.
The pattern would be “[0-9]{4,8}\-[0-9]”
Then, let’s change it from .Replace to .Match().Value
I don’t know if you ever figured this out but I am new here so I decided to take a break and try this since you have the data in Excel format. Record a macro then just replace the guts with the guts of this function. You could also paste this as-is and just call the function from the recorded macro.
Sub FindFormattedText()
’
’ FindFormattedText Macro
’
Dim i As Integer
Dim searchCol As String
Dim resultCol As String
searchCol = "A"
resultCol = "B"
For i = 2 To 100
currCol = Worksheets("Sheet1").Cells(i, searchCol).Value
If currCol Like "#######-#" Then
Worksheets("Sheet1").Cells(i, resultCol).Value = "YES"
End If
Next i