Sponsored Content
Top Forums Programming Regular Expression Help [Java] Post 302495818 by Noremak17 on Friday 11th of February 2011 09:53:03 AM
Old 02-11-2011
Question Regular Expression Help [Java]

So i'm trying to write a regular expression to help me pull id numbers from a string, the input would look something like:

"Product Name" stock=6 sid=0x000000000034c000 pid=0xd70

What I'd like is a regular expression that I could enter that would return just the pid value (and one for the sid value too). The problem is I can't be sure the pid or sid will always be the same length, so rather than the input above I might get an entry that says:

"Different Product Name" stock=45 sid=0x000000000034c000 pid=0xa11713

So in the first one I'd like the expression to cut out 0xd70 and in the second one I'd like it to cut out 0xa11713. If it is any help I know that the pid is never more than 8 characters long after the 0x, and that the sid is never more than 16 (I'm not sure if shipping id can be shorter than 16 or not).

I'm new to using regular expressions, and I've figured out hot to match then number entry when I know the length, but I can't figure it out for a variable length.

input1: "Product Name" stock=6 sid=0x000000000034c000 pid=0xd70
input2: "Product Name" stock=6 sid=0x000000000034c000 pid=0xa11713
regex: pid=.....
output1: pid=0xd70
output2: pid=0xa11 <-- missing 713

Thanks for the help.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular Expression + Aritmetical Expression

Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant. THX! (2 Replies)
Discussion started by: Z0mby
2 Replies

2. Shell Programming and Scripting

regular expression help

hello all.. I'm a bit new to this site.. and I hope to learn alot.. but I've been having a hard time figuring this out. I'm horrible with regular expressions.. so any help would be greatly appreciated. I have a file with a list of names like this: LASTNAME, FIRSTNAME, MIDDLEINITIAL how can... (5 Replies)
Discussion started by: mac2118
5 Replies

3. Linux

Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
2 Replies

4. Programming

java regular expression

Hello all, I need to match the red expression in the following lines : MACRO_P+P-_scrambledServices_REM_PRC30.xml MACRO_P+P-_scrambledServices_REM_RS636.xml MACRO_P+P-_scrambledServices_REM_RS535.xml and so on... Can anyone give me a regular expression to match those characters ? I am... (0 Replies)
Discussion started by: lsaas
0 Replies

5. Programming

Java regular expression help

Hi, I need to write a java regular expression that has the following rules: a) should not start with space or '.' (dot) character(s) b) should not contain spaces in between of the characters c) total characters length must be less than 80 d) should not be empty string Can anyone... (0 Replies)
Discussion started by: royalibrahim
0 Replies

6. Programming

Need Java regular expression

Hi, I am looking for a Java regular expression to match the below pattern of a java script file. var so = object.device.load('camera','value'); I want to grep out such lines present in the *.js files. The conditions are: a) the line may start with blank space(s) b) always the... (0 Replies)
Discussion started by: royalibrahim
0 Replies

7. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

8. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

9. Shell Programming and Scripting

Help with regular expression

I have file with following data, http://www.some.com/web11.html http://www.some.com/web/112.html http://www.some.com/web/21.html http://www.some.com/342.html http://www.some.com/plk.html http://www.some.com/abh.html http://www.some.com/yte.html http://www.some.com/tyr/098.html... (4 Replies)
Discussion started by: sol_nov
4 Replies

10. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies
AU_TOKEN(3)						   BSD Library Functions Manual 					       AU_TOKEN(3)

NAME
au_to_arg32, au_to_arg64, au_to_arg, au_to_attr64, au_to_data, au_to_exit, au_to_groups, au_to_newgroups, au_to_in_addr, au_to_in_addr_ex, au_to_ip, au_to_ipc, au_to_ipc_perm, au_to_iport, au_to_opaque, au_to_file, au_to_text, au_to_path, au_to_process32, au_to_process64, au_to_process, au_to_process32_ex, au_to_process64_ex, au_to_process_ex, au_to_return32, au_to_return64, au_to_return, au_to_seq, au_to_sock_inet32, au_to_sock_inet128, au_to_sock_inet, au_to_socket_ex, au_to_subject32, au_to_subject64, au_to_subject, au_to_subject32_ex, au_to_subject64_ex, au_to_subject_ex, au_to_me, au_to_exec_args, au_to_exec_env, au_to_header, au_to_header32, au_to_header64, au_to_header_ex, au_to_header32_ex, au_to_trailer, au_to_zonename -- routines for generating BSM audit tokens LIBRARY
Basic Security Module Library (libbsm, -lbsm) SYNOPSIS
#include <bsm/libbsm.h> token_t * au_to_arg32(char n, const char *text, u_int32_t v); token_t * au_to_arg64(char n, const char *text, u_int64_t v); token_t * au_to_arg(char n, const char *text, u_int32_t v); token_t * au_to_attr32(struct vattr *attr); token_t * au_to_attr64(struct vattr *attr); token_t * au_to_attr(struct vattr *attr); token_t * au_to_data(char unit_print, char unit_type, char unit_count, const char *p); token_t * au_to_exit(int retval, int err); token_t * au_to_groups(int *groups); token_t * au_to_newgroups(u_int16_t n, gid_t *groups); token_t * au_to_in_addr(struct in_addr *internet_addr); token_t * au_to_in_addr_ex(struct in6_addr *internet_addr); token_t * au_to_ip(struct ip *ip); token_t * au_to_ipc(char type, int id); token_t * au_to_ipc_perm(struct ipc_perm *perm); token_t * au_to_iport(u_int16_t iport); token_t * au_to_opaque(const char *data, u_int16_t bytes); token_t * au_to_file(const char *file, struct timeval tm); token_t * au_to_text(const char *text); token_t * au_to_path(const char *text); token_t * au_to_process32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); token_t * au_to_process64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); token_t * au_to_process32_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); token_t * au_to_process64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); token_t * au_to_return32(char status, u_int32_t ret); token_t * au_to_return64(char status, u_int64_t ret); token_t * au_to_return(char status, u_int32_t ret); token_t * au_to_seq(long audit_count); token_t * au_to_sock_inet32(struct sockaddr_in *so); token_t * au_to_sock_inet128(struct sockaddr_in6 *so); token_t * au_to_sock_int(struct sockaddr_in *so); token_t * au_to_socket_ex(u_short so_domain, u_short so_type, struct sockaddr *sa_local, struct sockaddr *sa_remote); token_t * au_to_subject32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); token_t * au_to_subject64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); token_t * au_to_subject(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); token_t * au_to_subject32_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); token_t * au_to_subject64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); token_t * au_to_subject_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); token_t * au_to_me(void); token_t * au_to_exec_args(char **argv); token_t * au_to_exec_env(char **envp); token_t * au_to_header(int rec_size, au_event_t e_type, au_emod_t emod); token_t * au_to_header32(int rec_size, au_event_t e_type, au_emod_t emod); token_t * au_to_header64(int rec_size, au_event_t e_type, au_emod_t e_mod); token_t * au_to_header_ex(int rec_size, au_event_t e_type, au_emod_t e_mod); token_t * au_to_header32_ex(int rec_size, au_event_t e_type, au_emod_t e_mod); token_t * au_to_trailer(int rec_size); token_t * au_to_zonename(const char *zonename); DESCRIPTION
These interfaces support the allocation of BSM audit tokens, represented by token_t, for various data types. au_errno_to_bsm(3) must be used to convert local errno(2) errors to BSM error numbers before they are passed to au_to_return(), au_to_return32(), and au_to_return64(). RETURN VALUES
On success, a pointer to a token_t will be returned; the allocated token_t can be freed via a call to au_free_token(3). On failure, NULL will be returned, and an error condition returned via errno. SEE ALSO
au_errno_to_bsm(3), libbsm(3) HISTORY
The OpenBSM implementation was created by McAfee Research, the security division of McAfee Inc., under contract to Apple Computer, Inc., in 2004. It was subsequently adopted by the TrustedBSD Project as the foundation for the OpenBSM distribution. AUTHORS
This software was created by Robert Watson, Wayne Salamon, and Suresh Krishnaswamy for McAfee Research, the security research division of McAfee, Inc., under contract to Apple Computer, Inc. The Basic Security Module (BSM) interface to audit records and audit event stream format were defined by Sun Microsystems. BSD
April 19, 2005 BSD
All times are GMT -4. The time now is 04:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy