Extracting date from the format [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am struggling through this date extraction. I have a date like this
("D("yyyy-mm-dd")).
I want to get this "yyyy-mm-dd" and I cannot strip ("D(") this also because I have this format in other places so I tried like this
first searching the string but I am not sure if I am on right track
eg. intabc = istrdate.SearchSubString("D(");
so please suggest how can I get this value.
Input is
"(D(YYYY-MM-DD))"
OUTPUT that I want
(YYYY-MM-DD)
What i have done(not correct way I think )
intabc = istrdate.SearchSubString("D(");

you can use substr() and string::erase() functions in c++98
string str = "\"D(\"yyyy-mm-dd\")";
string result = str.substr(3);
result.erase(result.end() - 1)
result.erase(result.end() - 1)
if you are using c++11 you can also use string::pop_back() method.

Related

How to "extract" string before "-" but if the string itself can contain a "-"? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have list of packages like this (it's bigger than this):
accounts-qml-module-0.7-3
accountsservice-0.6.55-3
alsa-firmware-1.2.1-2
alsa-oss-1.1.8-3
alsa-plugins-1:1.2.2-2
alsa-utils-1.2.3-2
augeas-1.12.0-2
baloo-5.74.0-1
baloo-widgets-20.08.1-1
binutils-2.35-2
breath2-icon-themes-1.0.10-2
breath2-wallpaper-1.0.10-2
bridge-utils-1.7-1
brltty-6.0-11
cfitsio-1:3.49-1
clucene-2.3.3.4-11
colord-sane-1.4.4+9+g1ce26da-2
confuse-3.3-1
containerd-1.4.1-1
convertlit-1.8-10
cpio-2.13-2
cracklib-2.9.7-2
cronie-1.5.5-1
cups-2.3.3-3
cups-filters-1.28.3-1
cups-pdf-3.0.1-5
cups-pk-helper-0.2.6-4
debootstrap-1.0.123-1
dhcpcd-9.2.0-1
diffutils-3.7-3
ding-libs-0.6.1-3
discount-2.2.7-1
djvulibre-3.5.27-6
dkms-2.8.3-1.1
docbook-xml-4.5-9
docbook-xsl-1.79.2-7
I'd like to have:
accounts-qml-module
accountsservice
alsa-firmware
alsa-oss
alsa-plugins
alsa-utils
augeas
baloo
baloo-widgets
but I don't really know how to do since there are some packets that have a "-" dash inside and I'm very confused about how could I achieve this avoiding to do it manually...
Is there a bash "trick" to do it?
try this regex :
^.+?(?=-[\d.\-:+]+)
demo

How to get value inside '[]' using regex? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
**Hi, I have written regex. in here i want select only value insdie **
[buttonRouter, CheckBoxModule, RadioButtonModule, DropDownButtonModule, SplitButtonModule, SwitchModule, SharedModule, ProgressButtonModule]
Instead of this it select
imports: [buttonRouter, CheckBoxModule, RadioButtonModule, DropDownButtonModule, SplitButtonModule, SwitchModule, SharedModule, ProgressButtonModule]
My requirement, regex has to select values only inside imports: [value]
This regex should return only return the value part but still look for "imports: ":
(?<!:imports: )\[.+\]

How to rename bunch of files via terminal, keeping the filenames prefix and suffix and removing wildcard in the middle? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Given +400 files such as :
Remi_Brun_-blablabla_blalala-ASpi777XisA.en.vtt
Remi_Brun_-not_important_but_here_to_nag-ZIBcQ5tMB2U.en.vtt
Remi_Brun_-still_some_wildcard_noise_here-hOxG4g05z4w.en.vtt
...
Given this regex match these titles :
(Remi_Brun)(_.+)([a-zA-Z0-9-_]{11}.en.vtt)
I want to rename my files into filenames such :
Remi_Brun-ASpi777XisA.en.vtt
Remi_Brun-ZIBcQ5tMB2U.en.vtt
Remi_Brun-hOxG4g05z4w.en.vtt
...
How to keep the speaker name prefix, remove the variable noise at the center, then keep the finale 11 characters youtube id and the extension suffix ?
If you want to remove everything between the first and last - before the youtube id, while allowing for any nonzero-sized language code, then this will work:
rename 's/-.*-([a-zA-Z0-9-_]{11}\..+\.vtt)/-\1/' Remi*
or for a more readable answer :
rename 's/(Remi_Brun)(_.+)([a-zA-Z0-9-_]{11}.en.vtt)/$1-$3/' Remi*
Edit:
My earlier answer
rename 's/-.*-/-/' Remi* #didn't account for hyphens in youtube id

Replace the words "can't, don't" by "can not, do not" using python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need to replace words like "{can't, don't, won't }" by "{can not, do not, would not}" using python
The problem is:
"can't" can be detected by checking suffix "n't", so we can replace "n't" by "not"
But how can we transform "ca" to "can" as when we split "can't" it should be transformed to "can not"?
Since the rules of English are large and sometimes inconsistent, your best bet is probably just to set up full word maps rather than trying to figure out on the fly which letters are represented by the apostrophe.
In other words, a dictionary with values like:
can't -> can not
don't -> do not
won't -> will not
:
oughtn't -> ought not

How to get filename structure in a folder in Matlab [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am designing a GUI in Matlab,
I have a folder called sth. It contains many files having same structure like,
filename_1_something.mat
filename_2_something.mat
In order to loop over filenames by selecting via index, I need to find a resulting string like this;
filename_%d_something.mat
So I don't need to read all the files in the dir. Two of the filenames are enough to compare strings and find the different char array item and change by %d.
Or anything different than this also appreciated.
using the regex provided by #rock321987 -
names = dir('*.mat');
num = length(names);
expression = '\w*_\d+_\w*\.mat';
for n = 1:num
str = names(n).name;
nameList{n} = regexp(str,expression,'match')
end
works on:
test_1_something.mat
test_10_something.mat
changing the regex to just \w*_\w*\.mat
works for
test_1.mat
1_test.mat
test_1_something.mat
test_10_something.mat
but also works for anything with an string joined by underscore .mat