I'm trying to match company names and ignore measurements/quantities. But I'm having a bit of trouble.
Example data:
8G Kingston Single DDR3-1600 CL11 Desktop RAM (KVR16N11/8)
8 Outlet Belkin Surge Protector With 2 Meter Cord
0.5M Yellow CAT6 Network Cable
100" Intact 16x -R DVD
15.6" Topload Notebook (Black)
120mm Aluminum Filter Silver
8P TP-Link 10/100 Desktop Switch
8Ware 0.5M CAT5E Network Cable
Acer Aspire Alpha 12" QHD IPS Display Intel Core i7 Touch Laptop
ACER Aspire E5 15.6" HD Intel Core i5 Laptop
Asus SDRW-08D2S-U Slim External USB 2.0 DVD Read/Writer - Black
I was hoping to match the company names but ignore the gigabytes (G) single digits, 100", 15.6" tokens etc.
So ideally it'd match:
Kingston Single DDR3-1600 CL11 Desktop RAM (KVR16N11/8)
Outlet Belkin Surge Protector With 2 Meter Cord
Yellow CAT6 Network Cable
Intact 16x -R DVD
Topload Notebook (Black)
Aluminum Filter Silver
TP-Link 10/100 Desktop Switch
8Ware 0.5M CAT5E Network Cable
Acer Aspire Alpha 12" QHD IPS Display Intel Core i7 Touch Laptop
ACER Aspire E5 15.6" HD Intel Core i5 Laptop
Asus SDRW-08D2S-U Slim External USB 2.0 DVD Read/Writer - Black
The expression I tweaked with is below, but I'm matching mm (the 120mm line) because I want the 8Ware matching.
Based upon the data you have provided, I have come up with a regex which you can use. Here is the sample code that you can run and see it prints your desired results.
public static void main(String[] args) {
List<String> dataList = new ArrayList<String>();
dataList.add("8G Kingston Single DDR3-1600 CL11 Desktop RAM (KVR16N11/8)");
dataList.add("8 Outlet Belkin Surge Protector With 2 Meter Cord");
dataList.add("0.5M Yellow CAT6 Network Cable");
dataList.add("100\" Intact 16x -R DVD");
dataList.add("15.6\" Topload Notebook (Black)");
dataList.add("120mm Aluminum Filter Silver");
dataList.add("8P TP-Link 10/100 Desktop Switch");
dataList.add("8Ware 0.5M CAT5E Network Cable");
dataList.add("Acer Aspire Alpha 12\" QHD IPS Display Intel Core i7 Touch Laptop");
dataList.add("ACER Aspire E5 15.6\" HD Intel Core i5 Laptop");
dataList.add("Asus SDRW-08D2S-U Slim External USB 2.0 DVD Read/Writer - Black");
System.out.println("Before:");
for (String s : dataList) {
System.out.println(s);
}
System.out.println();
System.out.println("After:");
for (String s : dataList) {
System.out.println(s.replaceAll("(^[0-9.]+[a-zA-Z\"]{0,2}\\s+)(.*)", "$2"));
}
}
Following is the output of this program upon running which is exactly what you wanted.
Before:
8G Kingston Single DDR3-1600 CL11 Desktop RAM (KVR16N11/8)
8 Outlet Belkin Surge Protector With 2 Meter Cord
0.5M Yellow CAT6 Network Cable
100" Intact 16x -R DVD
15.6" Topload Notebook (Black)
120mm Aluminum Filter Silver
8P TP-Link 10/100 Desktop Switch
8Ware 0.5M CAT5E Network Cable
Acer Aspire Alpha 12" QHD IPS Display Intel Core i7 Touch Laptop
ACER Aspire E5 15.6" HD Intel Core i5 Laptop
Asus SDRW-08D2S-U Slim External USB 2.0 DVD Read/Writer - Black
After:
Kingston Single DDR3-1600 CL11 Desktop RAM (KVR16N11/8)
Outlet Belkin Surge Protector With 2 Meter Cord
Yellow CAT6 Network Cable
Intact 16x -R DVD
Topload Notebook (Black)
Aluminum Filter Silver
TP-Link 10/100 Desktop Switch
8Ware 0.5M CAT5E Network Cable
Acer Aspire Alpha 12" QHD IPS Display Intel Core i7 Touch Laptop
ACER Aspire E5 15.6" HD Intel Core i5 Laptop
Asus SDRW-08D2S-U Slim External USB 2.0 DVD Read/Writer - Black
Like I said above, I have already given you a base regex and you may have to tweak it based upon your actual data if case you have more, else you are good already.
EDIT1:
Ok, as requested in comments, editing the answer to include the explanation of the regex.
(^[0-9.]+[a-zA-Z\"]{0,2}\s+)(.*)
The regex has two parts. First part (^[0-9.]+[a-zA-Z\"]{0,2}\s+) tries to match the measurements/quantities data. And second part just tries to match the remaining data which is supposedly the rest of the line. Elaborating only first part as second part (.*) is pretty trivial.
(^[0-9.]+[a-zA-Z\"]{0,2}\s+)
^ --> is for matching the start of data as measurement data is in the beginning of the line.
[0-9.]+ --> Matches the numbers one or more in the measurements/quantities data which can include a dot character.
[a-zA-Z\"]{0,2} --> This matches the units of data like G,M,mm," which according to given data can have length 0 to 2. E.g. "8 Outlet..." line does not have any units hence I had to use {0,2} else could have used {1,2}. And to avoid matching "8Ware ..." as measurement data, which you didn't want to match, I had to restrict the upper limit to 2.
\s+ is to just eat up one or more spaces present after measurement data.
So whole regex is matched and then replaced by $2, meaning only data captured by second part of regex (.*)
Hope that clarifies. Let me know in case you need explanation on any part further.
Related
Having difficulty with Power Automate Desktop, trying to convert this:
OS Name : Microsoft Windows 10 Pro
System Name : DESKTOP-VHCTR2M
Processor : Intel(R) Core(TM) i7 CPU 920 # 2.67GHz, 2668 Mhz, 4 Core(s), 8 Logical Processor(s)
BIOS Version/Date : American Megatrends Inc. 0504, 19/05/2009
BaseBoard Manufacturer : ASUSTeK Computer INC.
BaseBoard Product : P6T DELUXE V2
Platform Role : Desktop
Secure Boot State : Unsupported
Installed Physical Memory (RAM) : 32.0 GB
Remove all extra white spaces but keep the new line so the outcome would look like this:
OS Name : Microsoft Windows 10 Pro
System Name : DESKTOP-VHCTR2M
Processor : Intel(R) Core(TM) i7 CPU 920 # 2.67GHz, 2668 Mhz, 4 Core(s), 8 Logical Processor(s)
BIOS Version/Date : American Megatrends Inc. 0504, 19/05/2009
BaseBoard Manufacturer : ASUSTeK Computer INC.
BaseBoard Product : P6T DELUXE V2
Platform Role : Desktop
Secure Boot State : Unsupported
Installed Physical Memory (RAM) : 32.0 GB
So all text has 1 white space and not random spaces.
Any help will be appreciated.
[^\S\r\n]{2,}
This seems to work.
I have a scientific application which captures a video4Linux video stream. It's crucial that we capture each frame and no one gets lost. Unfortunately frames are missing here and there and I don't know why.
To detect dropped frames I compare the v4l2_buffer's sequence number with my own counter directly after reading a frame:
void detectDroppedFrame(v4l2_buffer* buffer) {
_frameCounter++;
auto isLastFrame = buffer->sequence == 0 && _frameCounter > 1;
if (!isLastFrame && _frameCounter != buffer->sequence+1)
{
std::cout << "\n####### WARNING! Missing frame detected!" << std::endl;
_frameCounter = buffer->sequence+1; // re-sync our counter with correct frame number from driver.
}
}
My running 1-file example gist can be found at github (based on official V4L2 capture example): https://gist.github.com/SebastianMartens/7d63f8300a0bcf0c7072a674b3ea4817
Tested with webcam on Ubuntu 18.04 virtual machine on notebook-hardware (uvcvideo driver) as well as with CSI camera on our embedded hardware running ubuntu 18.04 natively. Frames are not processed and buffers seems to be grabbed fast enough (buffer status checked with VIDIOC_QUERYBUF which shows that all buffers are in the driver's incoming queue and V4L2_BUF_FLAG_DONE flag is not set). I have lost frames with MMAP as well as with UserPtr method. Also it seems to be independent of pixelformat, image size and framerate!
To me it looks like if the camera/v4l2 driver is not able to fill available buffers fast enough but also increasing the file descriptor priority with VIDIOC_S_PRIORITY command does not help (still likely to be a thread scheduling problem?).
=> What are possible reasons why V4L2 does not forward frames (does not put them into it's outgoing queue)?
=> Is my method to detect lost frames correct? Are there other options or tools for that?
I had a similar problem when using the bttv driver. All attempts to capture at full resolution would result in dropped frames (usually around 10% of frames, often in bursts). Capturing at half resolution worked fine.
The solution that I found, though far from ideal, was to apply a load to the linux scheduler. Here is an example, using the "tvtime" program to do the capture:
#! /bin/bash
# apply a load in the background
while true; do /bin/true; done &> /dev/null &
# do the video capture
/usr/bin/tvtime "$#"
# kill the loop running in the background
pkill -P $$
This creates a loop that repeatedly runs /bin/true in the background. Almost any executable will do (I used /bin/date at first). The loop will create a heavy load, but with a multi-core system there is still plenty of headroom for other tasks.
This obviously isn't an ideal solution, but for what it's worth, it allows me to capture full-resolution video with no dropped frames. I have little desire to poke around in the driver/kernel code to find a better solution.
FYI, here are the details of my system:
OS: Ubuntu 20.04, kernel 5.4.0-42
MB: Gigabyte AB350M-D3H
CPU: AMD Ryzen 5 2400G
GPU: AMD Raven Ridge
Driver name : bttv
Card type : BT878 video (Hauppauge (bt878))
Bus info : PCI:0000:06:00.0
Driver version : 5.4.44
Capabilities : 0x85250015
I need to delete the content in the red rectangle in picture 1, and then generate a new text file.
Also, replace AIDA64 Engineer with AIDA64 Ultimate
Because the reserved fields are divided into different areas, for example: Motherboard:, it seems to be somewhat difficult
In the following post, some related issues have been resolved.
Get strings for some specific region
--------[ AIDA64 Engineer ]------------------------------------------------------------
version AIDA64 Engineer v6.00.5100/cn
--------[ System verview ]-------------------------------------------------------------
Motherboard:
Processor name Mobile DualCore Intel
DMI:
DMI BIOS Vendor Phoenix Technologies
--------[ DMI ]------------------------------------------------------------------------
[ BIOS ]
BIOS Attributes:
Vendor Phoenix Technologies Ltd.
[ Motherboard ]
Motherboard:
manufacturer Intel Corp.
Motherboard manufacturer:
company name Intel Corporation
--------[ Overclocking ]---------------------------------------------------------------
Motherboard:
Motherboard ID <DMI>
BIOS Attributes:
System BIOS date 12/24/2012
--------[ PCI/PnP Network ]------------------------------------------------------------
Atheros AR5009 802.11a/g/n Wireless PCI
Broadcom NetLink BCM57785 PCI-E PCI
Since the strings to remove seem to have nothing in common, this long regex replace might help:
$re = '\s+(DMI:\s+DMI BIOS Vendor|Motherboard manufacturer:\s+company name|BIOS Attributes:\s+System BIOS date)[^-]+'
$nlnl = ([Environment]::NewLine * 2) # replace with two newlines
(Get-Content -Path 'PATH TO THE FILE' -Raw) -replace $re, $nlnl -replace 'AIDA64 Engineer', 'AIDA64 Ultimate'
Result:
--------[ AIDA64 Ultimate ]------------------------------------------------------------
version AIDA64 Ultimate v6.00.5100/cn
--------[ System verview ]-------------------------------------------------------------
Motherboard:
Processor name Mobile DualCore Intel
--------[ DMI ]------------------------------------------------------------------------
[ BIOS ]
BIOS Attributes:
Vendor Phoenix Technologies Ltd.
[ Motherboard ]
Motherboard:
manufacturer Intel Corp.
--------[ Overclocking ]---------------------------------------------------------------
Motherboard:
Motherboard ID <DMI>
--------[ PCI/PnP Network ]------------------------------------------------------------
Atheros AR5009 802.11a/g/n Wireless PCI
Broadcom NetLink BCM57785 PCI-E PCI
Edit
If you only want to replace AIDA64 Engineer in the header and not also in the text later on, change this part:
-replace 'AIDA64 Engineer', 'AIDA64 Ultimate'
into
-replace '\[ AIDA64 Engineer \]', '[ AIDA64 Ultimate ]'
We have production machines running RedHat RHEL 5.11 / X.org version 7.1.1. The supplier of these machines provides a VirtualBox VM to allow software development on conventional computers, i.e. away from the production floor.
I would like to configure this VM for dual head / dual monitor / dual screen usage.
Step 1: The VM in VirtualBox Manager is configured for maximum video memory and 2 monitors.
Step 2: VirtualBox GuestAdditions are installed, version corresponding to the Virtual Box application.
Step 3: /etc/X11/xorg.conf is modified to support 2 devices, 2 screens and 2 monitors, all configured for the vboxvideo driver. The content is shown below:
# Xorg configuration created by system-config-display
Section "ServerLayout"
Identifier "Multihead layout"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" RightOf "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "LCD Panel 1600x1200"
EndSection
Section "Monitor"
Identifier "Monitor1"
VendorName "Monitor Vendor"
ModelName "LCD Panel 1600x1200"
EndSection
Section "Device"
Identifier "Videocard0"
Driver "vboxvideo"
BusID "PCI:0:2:0"
Screen 0
EndSection
Section "Device"
Identifier "Videocard1"
Driver "vboxvideo"
BusID "PCI:0:2:1"
Screen 1
EndSection
Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1600x1200" "1280x1024" "1280x960" "1280x800" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
EndSection
Section "Screen"
Identifier "Screen1"
Device "Videocard1"
Monitor "Monitor1"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1600x1200" "1280x1024" "1280x960" "1280x800" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
EndSection
Step 4: reboot the system
I expect now that the system is set-up and ready to show two screens on my computer. Alas, it only shows Screen0.
Observations:
/var/log/Xorg.0.log shows no errors, but a couple of warnings:
(WW) VBoxVideo(0): Failed to set up write-combining range (0xe0000000,0x8000000)
In the same log file, only the instance VBoxVideo(0) is mentioned; there is no reference to VBoxVideo(1)
lspci also shows only one instance of the VBox video driver:
00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
In VB Manager -> View only Virtual Screen 0 is said to be enabled; the other screen is available, but an "enable" option is presented, that appears to do nothing when selected.
Everything else I have seen seems to be consistent: the second screen is nowhere found on my RHEL VM.
Questions:
What is the importance of the warning on write-combining? Is this related to this problem?
Is vboxvideo driver / pseudo card a dual head card or should I instantiate a second card? What are the correct magic numbers for the BusID of the second "Device"?
Any other recommendation to get this configuration up-n-running?
I took the HDD serial number but it did not result in systems using AMD chipset. In the case of computer systems using RAID then how to get HDD serial number?
SelectQuery sq = new SelectQuery("SELECT Tag, SerialNumber FROM Win32_PhysicalMedia");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(sq); foreach (var i2 in searcher.Get()) { string Tag = i2["Tag"].ToString();
if (Tag != "\\.\PHYSICALDRIVE0")
continue;
string serial = i2["SerialNumber"].ToString();
File.WriteAllText("C:\Caditsys\Serial.txt", serial + Environment.NewLine + DateTime.Now.ToString("dd/MM/yyyy"));
Sometimes its easiest to leverage SmartMonTools. I'm assuming you are using software raid. SmartMonTools will usually tell you the serial number of anything plugged into the motherboard.
smartctl --scan
smartctl -i $yourdevice
If your disks are behind a hardware RAID controller, it gets trickier, but you can still use smartctl with the -d flag specific to your hardware device.