All Questions
787
questions
1
vote
2
answers
58
views
Regex doesn't match subgroups as expected
I am writing a C program that makes use of regex to detect a string like:
hl # # #
Where # indicates an integer. Up to 11 integer values should be captured here
I have written the following regular ...
-1
votes
0
answers
45
views
How can I do a regex replace that takes arbitrary characters in the string into consideration? [duplicate]
I have a piece of code which indexes a 1D as a 2D array like this:
#define N 10
#define INDEX(i, j) (i + j*N)
array[INDEX(2, 1)]
now having changed array to be a 2D array, I would like to replace ...
2
votes
1
answer
73
views
Matching word boundary does not work in C
I am trying to find out whether a full word, say test, exists in a sentence and I'd like to do it in a case-insensitive manner. I took advantage of regex capabilities in C and used \b in the pattern. ...
3
votes
3
answers
85
views
Extracing C structs into separate files with regex
I am cleaning up a C project which has a single header file that contains all used structs.
I want to extract all structs and put them into separate files using PowerShell Regex.
I have written the ...
3
votes
1
answer
70
views
Precompile regular expressions to object file data segment?
In order to avoid dynamic allocation, I would like to precompile regular expressions into binary objects that I can link into a final executable. PCRE2 has explicit support for serializing compiled ...
1
vote
1
answer
47
views
How to write a Flex code for matches protocol (http, https), domain name and optional port number, and path of the URL
How to write a Flex code for matches protocol (http, https), domain name and optional port number, and path of the URL
sample input:
http://google.com
https://google.com:6060
https://google.com:6060/...
0
votes
1
answer
55
views
How to use regular-expressions in C language
I'm a new bike in C language, after some simple examples and best practices of how to use regular expressions in ANSI C.
I have simple test, want to get date in an description string bellow
"{d(...
-1
votes
1
answer
70
views
Trouble copying, writing to file, writing to new string buffer and concatenating a string in C [duplicate]
Having trouble with operations to do with the above mentioned functions. I am however able to print the output using the printf(); function.
In an example to demo, we'll use the problematic write ...
0
votes
1
answer
99
views
POSIX Regex in C not matching
I am writing a program that deals with creating sockets in C and am using regex to validate the command line argument. The strings I need to match are either in the format:
192.168.1.1:80/index.html
...
1
vote
1
answer
120
views
Getting start and end of tokens in string with regular expressions
I am trying to implement some kind of syntax highlighting for C programs in C itself. Imagine I have stored all the source code I want to highlight into a string, and before printing it, I would like ...
1
vote
1
answer
95
views
How can I use regex to parse key:value pairs in a string?
void parseBuffer(char buffer[]) {
regex_t regex;
regmatch_t matches[3];
// Define the regular expression pattern
char pattern[] = "([^:]+):[[:space:]]*([^\\r\\n]+)[\\r\\n]*";...
-1
votes
1
answer
50
views
What is the proper way to test if a capturing group captured something in g_regex_split_simple
When using glib's g_regex_split_simple, what is the best way check if a capture group actually captured anything?
#include <glib.h>
#include <stdio.h>
int main() {
char *...
0
votes
1
answer
108
views
I am looking for a regular expression in python which will identify all the function bodies in a C file
I am looking for a RE in python which will identify all the C function
I want to automate the insertion of some comments at the start of each function,
For example a function looks like
static ...
0
votes
1
answer
45
views
C read strings from a file with complext format
So I have a file that looks like this:
9
$11$ pelle
$2$ pollo
$333$ palla
$41$ alla
$5078$ tta
$6$ tti
$7$ ll
$81$ er
$900$ ere
n = 9 is the number of key value pairs I want to read in my program.
so ...
0
votes
1
answer
84
views
C language: regexec returns not matching even the string matches the pattern
I use regex in the C language. I have the following code:
#include <regex.h>
static char input[] = "00001415_AXI_7_16";
static bool checkSn(char *input)
{
regex_t regex;
if (...