Get all groups from a regular expression match
Please help me understand how to use Java regular expressions:
I have an expression similar to this:
{noformat}"([^X]+)(X[^X]*)+"{noformat}This should match stuff like "asaasaXdfdfdfXXsdsfd".
How does one access all the matches for the second group (the second groups has a Kleene operator
added so it is not really just one group --- but match.groupCount() is always 2)
Here is roughly the code:
{noformat}java.util.regex.Pattern pattern = {noformat}{noformat}java.util.regex.Pattern.compile({noformat}{noformat}"([^X]+)(X[^X]*)+",{noformat}{noformat}java.util.regex.Pattern.MULTILINE{noformat}{noformat});{noformat}{noformat}java.util.regex.Matcher matcher = pattern.matcher(text);{noformat}{noformat}matcher.find();{noformat}{noformat}int groupcount = matcher.groupCount();{noformat}
Also, without matcher.find() I get an illegalStateException .. which I also get if I use matcher.matches() instead
of matcher.find().
I am obviously missing something here. There is always at least one "X" in the string so shouldn't that pattern always
match the whole string? Since there are often multiple X, shouldnt I get a group for each occurrence of X, followed
by 0 or more other characters?
{noformat}But when I try to match everything by using "^([^X]+)(X[^X]*)+$" I get an "IllegalStateException: No match available" again.{noformat}
What is the correct way to do this?
Edited by: johann_p on May 16, 2008 10:39 AM
I am sorry I messed this up. Here is a SSCCE:
import java.util.regex.Pattern;
import java.util.regex.Matcher;
class RegExp1 {
public static void main(String[] args) {
String testString = "first|aaaa | bbbb\n|cccc|ddddd";
Pattern pattern = Pattern.compile("^([^|]+)(\\|[^|]*)+$");
Matcher matcher = pattern.matcher(testString);
matcher.find();
int groupcount = matcher.groupCount();
System.out.println("Found "+groupcount+" groups");
System.out.println("Matcher: "+matcher);
for (int i = 1; i <= groupcount; i++) {
System.out.println("Match "+i+": "+testString.substring(matcher.start(i),matcher.end(i)));
}I figured out a small bug in my first code that explains some of the exception oddities, but my principal question remains:
how do I access all the matches that correspond to the second capturing group?
In the example I would get "first" for Match 1 and "|ddddd" for Match 2, but how do I access all the matches??
Thank you for your help!
Similar Messages
-
Get all groups from an AD Server
Hi everyone,
I'm trying to get all groups from and AD server.
Here's how I'm doing it:
DirContext ctx = new InitialDirContext( (Hashtable<String,String>) env);
Name n2 = new CompositeName().add(groupsContainer);
NamingEnumeration<Binding> contentsEnum = ctx.listBindings(n2);
int i = 1;
while ( contentsEnum.hasMore() && (i++) < 1000 )
Binding binding = contentsEnum.next();
groups.add(binding.getName().substring(3));
return groups; The problem is, I always get an error if I don't restrict the results number to below 1000.
The error is the following *javax.naming.SizeLimitExceededException: [LDAP: error code 4 - Sizelimit Exceeded];*
After googling, I found it it's due to a field in the AD Server, that restrict the result number.
So there is no way that I can obtain all groups without changing that field?
Regards,
Nuno.Hi Nuno,
You have to increase the MaxPageSize value at ActiveDirectory level to retrieve results more than 1000. By default the MaxPageSize value is 1000. There is no option other than increasing the MaxPageSize value.
Thanks & Regards,
Murali.
============ -
Hello everyone,
Well i'm having little problem to get all groups that exists in Weblogic. I already search but the only thing i can get is the groups from the user that is autenticated in the application.
Best regards,
Tiago MarquesSee if this helps - http://weblogic-wonders.com/weblogic/2010/11/10/list-users-and-groups-in-weblogic-using-jmx/
-
Get All group from LCES using Livecycle java API
Hello ,
Can anyone told me how i can retrieve all the groups that exist in my livecyle using JAVA API.
Some method who return all groups ??
Thanks!First Thank you for your answer
I tried this part
//Set connection properties required to invoke LiveCycle ES
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://test:1099");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,Service ClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
ServiceClientFactory scf = ServiceClientFactory.createInstance(connectionProps);
DirectoryManager directoryManager = new DirectoryManagerServiceClient(scf);
PrincipalSearchFilter psf = new PrincipalSearchFilter();
psf.setPrincipalType(Principal.PRINCIPALTYPE_GROUP); //Recommended - refines the search to a User or Group
psf.setRetrieveOnlyActive(); // Recommended - returns only ative users/groups and not obsolete/deleted users/groups
List<Principal> resultList = directoryManager.findPrincipals(psf);
System.out.println("Done");
and when I check the result of my list I find incomprehensible informations.
So when I debug the code , my list contains little information.
NB : my LDAP contains hundreds of groups.
Any suggestion
Any code Source. -
How to use a regural expression to get all digit from a string.
Hi All,
Do you know how to use regural expression to get all digits from the following string via ABAP program?
"'Log Attributes 0 ( 0 ) ( 10 % Available )"
Thanks,
AndrewHi,
Try the code mentioned below:
DATA: STR_LEN LIKE SY-FDPOS,
RSTR_LEN LIKE SY-FDPOS,
OFF LIKE SY-FDPOS.
DATA: IDX LIKE SY-FDPOS, "mn B20K054003
CL LIKE SY-FDPOS. "mn B20K054003
DATA: RSTRING(40).
DATA: STRING(40). " value 'A,N,I,L'.
FIELD-SYMBOLS: <NLS_CHAR>. "mn B20K054003
MOVE I_REGUH-ZNME1 TO STRING.
MOVE SPACE TO RSTRING.
STR_LEN = STRLEN( STRING ).
DESCRIBE FIELD RSTRING LENGTH RSTR_LEN.
IF RSTR_LEN < STR_LEN. RAISE TOO_SMALL. ENDIF.
WHILE IDX < STR_LEN. "mn B20K054003
ASSIGN STRING+IDX(*) TO <NLS_CHAR>. "mn B20K054003
IF SY-LANGU EQ '2'. "mn B20K054003
CALL FUNCTION 'NLS_THAI_CHARLEN' "mn B20K054003
EXPORTING "mn B20K054003
THAI_STRING = <NLS_CHAR> "mn B20K054003
CHANGING "mn B20K054003
THAI_CHARLEN = CL. "mn B20K054003
ELSE. "mn B20K054003
CL = CHARLEN( <NLS_CHAR> ). "mn B20K054003
ENDIF. "mn B20K054003
IF IDX NE 0. "mn B20K054003
SHIFT RSTRING RIGHT BY CL PLACES."mn B20K054003
ENDIF. "mn B20K054003
RSTRING+0(CL) = STRING+IDX(CL). "mn B20K054003
IDX = IDX + CL. "mn B20K054003
ENDWHILE. "mn B20K054003
Regds,
Anil
Edited by: Matt on Jul 1, 2009 9:36 AM -added code tags -
How get all record from master and matching record from detail
hi master
sir i have master detail table
i have many record in master table but some record in detail table how i get
all record from master and matching record from detail
such as
select m.accid,m.title,d.dr,d.cr from master m, detail d where m.accid=d.accid
this query not work that get only related record i need all record from master
please give me idea
thanking you
aamirhi master
sir i have master detail table
i have many record in master table but some record in
detail table how i get
all record from master and matching record from
detail
such as
select m.accid,m.title,d.dr,d.cr from master m,
detail d where m.accid=d.accid
this query not work that get only related record i
need all record from master
please give me idea
thanking you
aamir
select m.accid,m.title,d.dr,d.cr
from master m, detail d
where m.accid=d.accid (+)The outer join operator (+) will get you all the details from master and any details from the detail if they exist, but the master details will still be got even if there are not details.
Note: Oracle 10g now supports ANSI standard outer joins as in:
select m.accid,m.title,d.dr,d.cr
from master m LEFT OUTER JOIN detail d on m.accid=d.accid -
How to get the meaning of the regular expression?
Hello All,
I want to know how to get the meaning of the regular expression?
The requirement is i need to get the regular expression for some of the attributes and if the value is not matching with that regular expression then i need to give the popup saying the limitation of the attribute. but i need to give the pop up with the user understanding format.
Like "please give a to z or 1 to 9" like that.
So is there any way Java will help me to get the meaning of the regular expression?
Thank You!
Arun SI'm not aware of any such tool or library.
Also, it would be a terrible "explanation", because regular expressions (similar to other programming languages) have their own "style" of defining what to enter and that usually doesn't translate well into natural language.
For example the regex "[a-z][a-z0-9]*\s+[a-z0-9]+" could be translated as "a to z, followed by zero or more characters from a to z or 0 to 9 followed by any amount of whitespace followed by one or more characters from a to z or 0 to 9".
Or you could simply say "Please enter two alphanumeric words, the first one must not start with a number".
My suggestion: store/configure the human-readable description together with the regex. Don't try to automate it. -
How do I get all music from my iPod classic to itunes on my computer?
How do I get all music from my iPod classic to itunes on my computer? I was able to "authorize" the purchased music (40 songs) to download to laptop but I can't select my entire library (1500 songs) to download to laptop!
Recover media from iPod
See this post from forum regular Zevoneer for options on moving your iPod data back to your computer.
tt2 -
Sharepoint 2010 get User Groups from specific site
Hello,
I was able to get all User groups from entire site Collection.
But instead of getting user groups from entire site, I want read user groups only from one specified sub site.
Please help!
ThanksAssuming you have an SPWeb object named "web", example:
SPSite site = new SPSite(http://yourdomain/sites/yoursite);
SPWeb web = site.OpenWeb("mysubsite/subsbusite");
web.Groups will return a collection of SPGroup objects for the current subsite. If this subsite inherits permissions from a parent site (web.HasUniquePerm = False), the list is the same as the Groups property of the parent site.
SPWeb.Groups:
http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.spweb.groups(v=office.15).aspx
SPGroup:
http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.spgroup(v=office.15).aspx
You would be better results by posting coding questions in "SharePoint 2010 - Development and Programming" instead of "SharePoint 2010 - General Discussions and Questions".
Mike Smith TechTrainingNotes.blogspot.com
Books:
SharePoint 2007 2010 Customization for the Site Owner,
SharePoint 2010 Security for the Site Owner -
Hi guys,
I am developing an integration with EWS based on php. I am using a library I found https://github.com/jamesiarmes/php-ews
In my case users have various calendars hanging from the root, I get access to the default calendar by this:
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$response = $ews->FindFolder($request);
I also get access to shared calendars by this:
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::PUBLIC_FOLDERS_ROOT;
$response = $ews->FindFolder($request);
But I am getting crazy to get all calendars hanging from the root. If I asked for all folders on the root I don't get those calendars. What service and params do I need to send to get all calendars from the root?
Thanks!!If you make a FindFolder Request set the Traversal to Deep and use a restriction on the FolderClass to IPF.Appointment that should return all the Calendar folders in a mailbox eg
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="
http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://sc
hemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xml
soap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:FindFolder Traversal="Deep">
<m:FolderShape>
<t:BaseShape>AllProperties</t:BaseShape>
</m:FolderShape>
<m:IndexedPageFolderView MaxEntriesReturned="1000" Offset="0" BasePoint=
"Beginning" />
<m:Restriction>
<t:IsEqualTo>
<t:FieldURI FieldURI="folder:FolderClass" />
<t:FieldURIOrConstant>
<t:Constant Value="IPF.Appointment" />
</t:FieldURIOrConstant>
</t:IsEqualTo>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="msgfolderroot" />
</m:ParentFolderIds>
</m:FindFolder>
</soap:Body>
</soap:Envelope>
Cheers
Glen -
How can i get all values from jtable with out selecting?
i have one input table and two output tables (name it as output1, output2). Selected rows from input table are displayed in output1 table. The data in output1 table is temporary(means the dat wont store in database just for display purpose).
Actually what i want is how can i get all values from output1 table to output2 table with out selecting the data in output1 table?
thanks in advance.
rajaYou could set the table's data model to be the same:
output2.setModel( output1.getModel() ); -
How do I get all contacts from my iphone 4 to icloud?
how do I get all contacts from my iphone 4 to icloud? I've just got some of them.
All you have to do is enable iCloud on your phone and turn notes on. They should automatically appear on your phone.
-
How to get all images from folder in c#?
I am trying to get all images from folder. But it is not executing from following:
string path=@"C:\wamp\www\fileupload\user_data";
string[] filePaths = Directory.GetFiles(path,".jpg");
for (int i = 0; i < filePaths.Length; i++)
dataGridImage.Controls.Add(filePaths[i]);
Please give me the correct solution.How to display all images from folder in picturebox in c#?
private void Form1_Load(object sender, EventArgs e)
string[] files = Directory.GetFiles(Form1.programdir + "\\card_images", "*", SearchOption.TopDirectoryOnly);
foreach (var filename in files)
Bitmap bmp = null;
try
bmp = new Bitmap(filename);
catch (Exception e)
// remove this if you don't want to see the exception message
MessageBox.Show(e.Message);
continue;
var card = new PictureBox();
card.BackgroundImage = bmp;
card.Padding = new Padding(0);
card.BackgroundImageLayout = ImageLayout.Stretch;
card.MouseDown += new MouseEventHandler(card_click);
card.Size = new Size((int)(this.ClientSize.Width / 2) - 15, images.Height);
images.Controls.Add(card);
Free .NET Barcode Generator & Scanner supporting over 40 kinds of 1D & 2D symbologies. -
How to get all data from nokia to i5s
how to get all data from nokia E71 to i5s???
if you can put those data in your computer then add it in iTunes. your iPhone 5s should get it thru syncing.
-
Cannot get all updates from iTunes software
Hello. There is a strange problem.
Sometimes, when I open iTunes from my computer, a small number will be displayed after "Apps".
When I click the "Apps", I can also see that there are some updates available from the bottom link text.
But after I click that bottom link, I cannot get all programs which need to be update listed. When I update all listed, iTunes still says there are some apps to be updated, but when I click that bottom link, only a text "No updates are currently available. To check for updates for another Apple ID, sign in with that Apple ID."
At that time, I can get all updates from my iPhone - Apple Store. So all have to do, is update all apps from my iPhone and sync it back. But if some apps are not installed on this iPhone, I have no way to update it.
BTW, I've tried to click Store - Check for available downloads from iTunes on my computer. It's useless in this case.
Any solution? Thanks.It think its a bug. I got the same results under MX 7.0.2.
The topic of maxrows recently came up on another thread. I
did some searching and according to TechNote 18339 there was a
change with maxrow
"<cfquery maxrows=N> bug. ColdFusion MX (until ColdFusion
MX 7.0.1 CHF2) didn't pass maxrows to the underlying driver
(statement.setMaxRows())"
Given the results you're getting, it sounds like CF is
applying the maxrow to all of the resultsets, not just the one
where maxrows was declared. I suspect cfstoredproc's usage of
statement.setMaxRows() is incorrect. Thats just a guess though.
Bottom line, I think you'll need handle it manually.
Personally, I would recommend placing the row count logic in the
stored procedure (if possible). The overall results will be more
consistent and you won't have to worry about this kind of issue
again.
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_18339
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000314.htm
http://www.remotesynthesis.com/blog/index.cfm/2006/3/23/Maxrows-Issue-in-CFQuery
Maybe you are looking for
-
Hello, I am preparing a default text for a textbox like this: ="Guten Tag Herr "&@name&", Ihr Darlehensantrag wurde geprüft und bewilligt. foobar..." What is the trick to insert linebreaks ? (the in the example does not work...) Thanks, Kai
-
Can some explain vpc peer-link vlan issues for me?
I remove vlan from vpn peer-link , the vpc is gonna down. I know this is design ,but why. thank you! Tom
-
Link in Flash keeps opening in new window
I have l a flash file in my pages that links to other pages within my web site but when clicked they automatically open in another window. How can I link them without opening a new window as would happen with a normal web page link? Here is my curre
-
Hi All, 60004375 is the Spares cust returns that was done in VA01. When trying to return this part back to 3806(plant), M001(s.loc) under the transaction(MIGO) " Transfer Posting movement type 453" the following error was encountered. help to che
-
Please, kindly help to find out why Photoshop fills a selection with transparent color while opacity and fill of a layer are set to 100% and blending modes are "normal" Thank you!