I have the following regular expression:

\S*\.(jpg|gif|png)$

which I have tested in multiple online Javascript testers, and it works. 
 The intent is to match filenames for image files. (e.g. 
"myimagefilename.jpg").

my code to set this up is below.  When I step through it I find the 
following:

1. The regular expression looks valid, meaning at runtime the 
IMAGE_FILE_PATTERN has proper javascript form:  /\S*\.(jpg|png|gif|bmp)$/gi
2. The following filename -> "DSC_0001.JPG" evaluates to false when tested 
against the IMAGE_FILE_PATTERN.
3. The ignoreCase attribute returns true on the IMAGE_FILE_PATTERN.

Anyone have any suggestions on why this keeps evaluating to false with all 
of my image file names?

public class MyClass {


protected static final RegExp IMAGE_FILE_PATTERN = RegExp.compile(
"\\S*\\.(jpg|png|gif|bmp)$", "gi");


public CarouselWidget(JSONArray fileList) {

 Image img;

 JSONValue val;

 JSONString jString;

 String urlFragment;

 boolean match;


 int size = fileList.size();

  for(int index=0; index<size; index++) {

 val = fileList.get(index);

   jString = val.isString();

   if (jString != null) {

    urlFragment = jString.toString();

  match = IMAGE_FILE_PATTERN.test(urlFragment);

  @SuppressWarnings("unused")

  boolean ignoreCase = IMAGE_FILE_PATTERN.getIgnoreCase();

    if (match) {

  img = new Image(ImageBrowserEntryPoint.baseUrl + "/" + urlFragment);

  img.addClickHandler(new ImageClickHandler(tPanel, urlFragment));

  hPanel.add(img);

  }

   }

 }

}

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to