Format a C++ string with template [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
What is the best way to transform a string with a special template, like a sed unix transform.
i must to do this with QT c++ :
original string : 00048500854006F85FF4B0
before c++ transform : 48500854006F85FF4B
Eliminate all the 0 in the start and the end of my string (not in the middle).
maybe a solution with sprintf ?
thank you very much for your help.

It's possible to do using regular expression:
QString("00048500854006F85FF4B0").remove(QRegExp("(^(0)+)|((0)+$)"));

You can always use the power of sed by calling system ("sed 's/foo/bar/' file"); or by using the Qt QProcess. In that case see this and this

Related

I need basic regex code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
/edit?o=U&video_id=xxxxxxxxxxxx&show_mt=1
/edit?o=U&show_mt=1&video_id=xxxxxxxxxxxx
I want get video_id query using regex (xxxxxxxxx)
I am using VB.NET
Thanks for help!
M. Deger
Edit: I want only regex code eg: [^?]+(?:\?video_id=([^&]+).*)?
Untested:
(?<=video_id\s*=\s*)[^&]*(?=&|$)
or, result in capture group 1
video_id\s*=\s*([^&]*)(?:&|$)

Regular expression for all lower case with _ allowed [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
what is the regular expression to validate a string. the string should contain
all lower case
_ is allowed in the string.
Thanks in advance.
You need to use regex pattern
^[a-z_]*$
You can use a POSIX class as an alternative to a simple character class to achieve this:
[[:lower:]_]*

regualr expression letters and word match [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
apologies for what is probably a really simple question but I am a complete noob when it come to using regular expressions.
I am trying to create an expression that matches some set criteria together, and although I can find the code to validate these things separately I'm struggling to understand how you put it all together.
What I am looking for is an expression that validates an entered code:
It will always a start with either OR or TR and then you will have 6 digits after that e.g. TR002563
Any help would be greatly appreciated.
Try this regex:
/^(?:O|T)R[0-9]{6}$/
You can use this regex:
/^[OT]R[0-9]{6}$/

RegEx - Add new conditions to existing regex [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I currently have this Regex:
.*[a-z]$|.*[A-Z]$|.*[0-9]$
I need to add the following to the existing - /:.#[]()
Does anyone know how to do it?
You don't need multiple OR conditions. Have only one and include special characters also:
[0-9A-Za-z\/#:.()\[\]]
Per your comments, this should do it for you:
^[a-zA-Z0-9/:.#\[\]()]+$
This will match a string containing only the characters you've specified.

I'm confused by a simple regex: I need to match something like [Test] but not Test [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
How would I go about writing a regex to match the first example, but not the second?
Thank you --
Try
\[Test\]
You need to escape the [ and ] as they indicate range start/end.
[] are special characters for a regex, used for defining a character class, therefore escape them with backslashes.
\[Test\]
If you use [Test], it will match a single character which is either T, e, s or t.