Jump to content
UBot Underground

[Solved]RegEx How to place items on one line


Recommended Posts

Hi all,

 

I am new to RegEx always stayed away from it (don't know why). Anyway it's come the time i need to use it for things, so the past week i have been messing about with it in some bots.

 

I've come across a problem, I have a list of items in a list now out of that list i want to grab all the numbers only so i use set(#Hk, $find regular expression(%RHID, "\\d"), "Global")

 

which does put all the numbers out the list %RHID into the variable #Hk BUT it puts 1 number per line. I want all these numbers as a large string. I have tried using \r but im not sure exactly how to do it. I even looked at RegExBuddy but couldn't find out in there how to do it either.

 

Can anyone help please?

 

Thanx in advance

 

Jane

Link to post
Share on other sites

Hi Jane.

 

Can you give an example url so I can take a look? You may be able to do something as simple as replace a new line with a space (if you need a space) or nothing if you don't.

 

 

John

Link to post
Share on other sites

Hi Jane.

 

Can you give an example url so I can take a look? You may be able to do something as simple as replace a new line with a space (if you need a space) or nothing if you don't.

 

 

John

 

Hi John,

 

It's not a url, Im reading it from a csv file into a list. Here is a cut down example of the list items and then how the variable looks in the debugger.

 

 

 

(9): SoundDevice, Caption = Realtek High Definition Audio; ConfigManagerErrorCode = 0; ConfigManagerUserConfig = False; CreationClassName = Win32_SoundDevice; Description = Realtek High Definition Audio; DeviceID = HDAUDIO\FUNC_01&VEN_10EC&DEV_0889&SUBSYS_10250146&REV_1000\4&333E2D5D&0&0001; Manufacturer = Realtek; Name = Realtek High Definition Audio; PNPDeviceID = HDAUDIO\FUNC_01&VEN_10EC&DEV_0889&SUBSYS_10250146&REV_1000\4&333E2D5D&0&0001; PowerManagementSupported = False; ProductName = Realtek High Definition Audio; Status = OK; StatusInfo = 3; SystemCreationClassName = Win32_ComputerSystem; SystemName = LAPPY; Caption = NVIDIA HDMI Audio; ConfigManagerErrorCode = 0; ConfigManagerUserConfig = False; CreationClassName = Win32_SoundDevice; Description = NVIDIA HDMI Audio; DeviceID = HDAUDIO\FUNC_01&VEN_10DE&DEV_0006&SUBSYS_10DE0101&REV_1000\4&333E2D5D&0&0201; Manufacturer = NVIDIA; Name = NVIDIA HDMI Audio; PNPDeviceID = HDAUDIO\FUNC_01&VEN_10DE&DEV_0006&SUBSYS_10DE0101&REV_1000\4&333E2D5D&0&0201; PowerManagementSupported = False; ProductName = NVIDIA HDMI Audio; Status = OK; StatusInfo = 3; SystemCreationClassName = Win32_ComputerSystem; SystemName = LAPPY

(10): DesktopMonitor, Availability = 3; Caption = Generic PnP Monitor; ConfigManagerErrorCode = 0; ConfigManagerUserConfig = False; CreationClassName = Win32_DesktopMonitor; Description = Generic PnP Monitor; DeviceID = DesktopMonitor1; MonitorManufacturer = (Standard monitor types); MonitorType = Generic PnP Monitor; Name = Generic PnP Monitor; PixelsPerXLogicalInch = 120; PixelsPerYLogicalInch = 120; PNPDeviceID = DISPLAY\SEC304C\5&16FD7C7&0&UID272; ScreenHeight = 768; ScreenWidth = 1280; Status = OK; SystemCreationClassName = Win32_ComputerSystem; SystemName = LAPPY

(12): MemoryDevice, Caption = Memory Device; CreationClassName = Win32_MemoryDevice; Description = Memory Device; DeviceID = Memory Device 0; EndingAddress = 2097151; ErrorInfo = 3; Name = Memory Device; StartingAddress = 0; SystemCreationClassName = Win32_ComputerSystem; SystemName = LAPPY; Caption = Memory Device; CreationClassName = Win32_MemoryDevice; Description = Memory Device; DeviceID = Memory Device 1; EndingAddress = 2097151; ErrorInfo = 3; Name = Memory Device; StartingAddress = 0; SystemCreationClassName = Win32_ComputerSystem; SystemName = LAPPY

 

#Hk: 3

3

2

2

0

2

3

2

1

0

1

1

0

2

0

3

2

0

3

 

 

so I want the numbers returned to be in 1 string on one line for example 12345567 and not how they are above 1 per line.

 

Hope I explained it ok?

 

 

Jane

Link to post
Share on other sites

I'm not positive I follow, but you can do something like this:

 

set(#list, "3

2

2

0

2

3

2

1

0

1

1

0

2

0

3

2

0

3", "Global")

set(#list, $replace($list from text(#list, $new line), $new line, $nothing), "Global")

 

 

 

 

 

John

Link to post
Share on other sites

I'm not positive I follow, but you can do something like this:

 

set(#list, "3

2

2

0

2

3

2

1

0

1

1

0

2

0

3

2

0

3", "Global")

set(#list, $replace($list from text(#list, $new line), $new line, $nothing), "Global")

 

 

 

 

 

John

 

 

Thanks john,

 

That did the trick. I didn't even think about doing it in ubot ..lol

 

Thanks again

 

Jane

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...