Java.util.regex.pattern.error
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up java.util.regex.PatternSyntaxException up vote 0 down vote favorite I have modified the BluetoothChat code to receive serial data from a micro-controller to my android phone. When I run the following code snippet it gives java.util.regex.PatternSyntaxException. What exactly is the error? Why is this exception happening? BluetoothChat.java // The Handler that gets information back from the BluetoothChatService private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_WRITE: byte[] writeBuf = (byte[]) msg.obj; // construct a string from the buffer String writeMessage = new String(writeBuf); mConversationArrayAdapter.add(writeMessage); break; case MESSAGE_READ: byte[] readBuf = (byte[]) msg.obj; // construct a string from the valid bytes in the buffer String readMessage = new String(readBuf, 0, msg.arg1); if(readMessage.matches("*")) { mConversationArrayAdapter.add("Left"); } else {mConversationArrayAdapter.add(readMessage);} } Log-cat: 09-15 13:54:32.070: E/AndroidRuntime(21931): FATAL EXCEPTION: main 09-15 13:54:32.070: E/AndroidRuntime(21931): java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 1: 09-15 13:54:32.070: E/AndroidRuntime(21931): * 09-15 13:54:32.070: E/AndroidRuntime(21931): ^ 09-15 13:54:32.070: E/AndroidRuntime(21931): at java.util.regex.Pattern.compileImpl(Native Method) 09-15 13:54:32.070: E/AndroidRuntime(21931): at java.util.regex.Pattern.compile(Pattern.java:400) 09-15 13:54:32.070: E/AndroidRuntime(21931): at java.util.regex.Pattern.
and DropEventsExpandableListViewGridViewHorizontalScrollViewImageButtonImageViewLinearLayoutListViewNotificationsPasswordProgressBarProgressDialogRadioButtonRadioGroupRatingBarRelativeLayoutScrollViewSelectorSettingsSpinnerSurfaceViewTextBoxTimePickerToastToggleButtonWebViewviewMenuOnClickListenerViewPagerwidgetAutoCompleteTextViewEditTextFrameLayoutSeekBarSlidingDrawerStackViewTextViewViewFlipperxmlgamescanvasmain loopOpenGL ESCore JavaanimationapacheANTcommonsbeanutilsconvertersArrayConvertercliBasicParsercodecbinaryBase64Base64OutputStreamcsvdbcpBasicDatasourcePoolingConnectioniocomparatorCompositeFileComparatorDirectoryFileComparatorLastModifiedFileComparatorNameFileComparatorPathFileComparatorFilenameUtilsFileUtilsIOUtilsmonitorFileAlterationMonitorlang3CharUtilsClassPathUtilsmathFractionNumberUtilsStringUtilsloggingLogfactorynetCookieStoreFTPClientURLClassLoaderURLConnectionluceneappletaspectjbeanscajoCharacterclassComperablecryptoDesign PatternsdecoratorstrategyGenericsGradlegsonGsonBuilderstreamJsonReaderJsonWriterioBufferedInputStreamBufferedOutputStreamBufferedReaderBufferedWriterByteArrayInputStreamByteArrayOutputStreamConsoleDataInputStreamDataOutputStreamExternalizableFileFileDescriptorFileInputStreamFilenameFilterFileOutputStreamFileReaderFileWriterInputStreamInputStreamReaderIOExceptionObjectInputStreamObjectOutputStreamOutputStreamPrintWriterRandomAccessFileSerializableStreamTokenizerStringReaderStringWriterjsonJacksonJSON.SimplejunitlangmanagementNumberFormatExceptionProcessBuilderReferenceQueueRunnableRuntimeStringStringBufferStringBuilderSystemmathMockitonetAuthenticatorConnectExceptionCookieManagerCookieStoreDatagramPacketHttpCookieInetAddressJarURLConnectionMalformedURLExceptionMulticastSocketNetworkInterfaceServerSocketSocketSocketExceptionSocketTimeoutExceptionUnknownHostExceptionURISyntaxExceptionURLURLClassLoaderURLConnectionURLDecoderURLEncodernioBufferByteBufferchannelsAsynchronousChannelGroupAsynchronousFileChannelAsynchronousSocketChannelCompletionHandlerFileLockScatteringByteChannelSelectorspiSelectorProviderCharBufferfilePathWatchEventFileChannelFileLockMappedByteBufferPowerMockitoreflectionrmiRemo
Method java.util.regex Class Pattern java.lang.Object java.util.regex.Pattern All Implemented Interfaces: Serializable public final class Pattern extends Object implements Serializable A compiled representation of a regular expression. A regular expression, specified as a string, must first be compiled https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html into an instance of this class. The resulting pattern can then be used to create a Matcher object that can match arbitrary character sequences against the regular expression. All of the state involved in https://github.com/lwhite1/tablesaw/issues/86 performing a match resides in the matcher, so many matchers can share the same pattern. A typical invocation sequence is thus Pattern p = Pattern.compile("a*b"); Matcher m = p.matcher("aaaaab"); boolean b = m.matches(); A matches method is defined by this class as a convenience for when a regular expression is used just once. This method compiles an expression and matches an input sequence against it in a single invocation. The statement boolean b = Pattern.matches("a*b", "aaaaab"); is equivalent to the three statements above, though for repeated matches it is less efficient since it does not allow the compiled pattern to be reused. Instances of this class are immutable and are safe for use by multiple concurrent threads. Instances of the Matcher class are not safe for such use. Summary of regular-expression constructs Construct Matches Characters x The character x \\ The backslash character \0n The character with octal value 0n (0<=n<=7) \0nn The character with octal value 0nn (0<=n<=7) \0mnn The character with octal value 0mnn (0<=m<=3, 0<=n<=7) \xhh The character with hexadecimalvalue0xhh \uhhhh The character with hexadecimalvalue0xhhhh \x{h...h} The character with hexadecimalvalue0xh...h (Character.MIN_CODE_POINT <=0xh...h<=  Character.MAX_CODE_POINT) \t The tab character ('\u0009') \n The newline (line feed) character ('\u000A') \r The carriage-return character ('\u000D') \f The form-feed character ('\u000C') \a The alert (bell) character ('\u0007') \e The escape character ('\u001B') \cx The control character corresponding to x Character classes [abc] a, b, or c (simple class) [^abc] Any character except a, b, or c (negation) [a-zA-Z] a through z or A through Z, inclusive (range) [a-d[m-p]] a through d, or m through p: [a-dm-p] (union) [a-z&&[def]] d, e, or f (intersection) [a-z&&[^bc]] a through z, except for b and c: [ad-z] (subtraction) [a-z&&[^m-p]] a through z, and not m through p: [a-lq-z](subtraction) Predefined character classes . Any character
Sign in Pricing Blog Support Search GitHub This repository Watch 54 Star 358 Fork 88 lwhite1/tablesaw Code Issues 34 Pull requests 1 Projects 0 Wiki Pulse Graphs New issue throwed java.util.regex.PatternSyntaxException for run on windows #86 Closed rocbin opened this Issue Aug 28, 2016 · 1 comment Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 2 participants rocbin commented Aug 28, 2016 Hello! I first test your demo on my windows 10 compute, that has an error: Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Pattern.java:1955) at java.util.regex.Pattern.compile(Pattern.java:1702) at java.util.regex.Pattern.(Pattern.java:1351) at java.util.regex.Pattern.compile(Pattern.java:1028) at com.rocbin.tablesaw.study.LargeDataTest.main(LargeDataTest.java:32) this error at com.github.lwhite1.tablesaw.store.StorageManager.java in LINE-40. cause is : windows platform, File.separator must be '\', haha, do you tested on windows? fixed: private static final Pattern SEPARATOR_PATTERN = "\\".equals(File.separator) ? Pattern.compile("\\\\") : Pattern.compile(File.separator); lwhite1 added a commit that referenced this issue Sep 30, 2016 lwhite1 #86